Embedding a template for SVG element instead of just styles
This commit is contained in:
@@ -60,32 +60,22 @@ describe('parser/javascript.js', function() {
|
||||
this.parser.parsed = jasmine.createSpyObj('parsed', ['render']);
|
||||
this.parser.parsed.render.and.returnValue(this.renderPromise.promise);
|
||||
|
||||
this.svgStyles = 'example styles';
|
||||
this.svgBase = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1"></svt>';
|
||||
this.svgContainer = document.createElement('div');
|
||||
});
|
||||
|
||||
it('creates the SVG element', function() {
|
||||
var svg;
|
||||
|
||||
this.parser.render(this.svgContainer, this.svgStyles);
|
||||
this.parser.render(this.svgContainer, this.svgBase);
|
||||
|
||||
svg = this.svgContainer.querySelector('svg');
|
||||
expect(svg.getAttribute('xmlns')).toEqual('http://www.w3.org/2000/svg');
|
||||
expect(svg.getAttribute('version')).toEqual('1.1');
|
||||
});
|
||||
|
||||
it('sets the styles on the SVG element', function() {
|
||||
var styles;
|
||||
|
||||
this.parser.render(this.svgContainer, this.svgStyles);
|
||||
|
||||
styles = this.svgContainer.querySelector('svg defs style');
|
||||
expect(styles.getAttribute('type')).toEqual('text/css');
|
||||
expect(styles.firstChild.nodeValue).toEqual(this.svgStyles);
|
||||
});
|
||||
|
||||
it('render the parsed expression', function() {
|
||||
this.parser.render(this.svgContainer, this.svgStyles);
|
||||
this.parser.render(this.svgContainer, this.svgBase);
|
||||
expect(this.parser.parsed.render).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -100,7 +90,7 @@ describe('parser/javascript.js', function() {
|
||||
height: 24
|
||||
});
|
||||
|
||||
this.parser.render(this.svgContainer, this.svgStyles);
|
||||
this.parser.render(this.svgContainer, this.svgBase);
|
||||
this.renderPromise.resolve(this.result);
|
||||
|
||||
setTimeout(done, 10);
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('regexper.js', function() {
|
||||
'<div><a href="#" data-glyph="data-transfer-download"></a></div>',
|
||||
'<div id="progress"><div></div></div>',
|
||||
'<div id="regexp-render"></div>',
|
||||
'<div id="svg-styles">example styles</div>'
|
||||
'<script type="text/html" id="svg-base"><svg></svg></script>'
|
||||
].join('');
|
||||
|
||||
this.regexper = new Regexper(this.root);
|
||||
@@ -429,7 +429,7 @@ describe('regexper.js', function() {
|
||||
});
|
||||
|
||||
it('renders the expression', function() {
|
||||
expect(this.parser.render).toHaveBeenCalledWith(this.regexper.svgContainer, this.regexper.svgStyles);
|
||||
expect(this.parser.render).toHaveBeenCalledWith(this.regexper.svgContainer, this.regexper.svgBase);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user