it('works without a parent', () => {
const canvas = new Svg()
- expect(canvas.xml('<rect /><circle>', undefined, svg)).toBe(canvas)
+ expect(canvas.xml('<rect /><circle />', undefined, svg)).toBe(canvas)
})
})
describe('selector.js', () => {
describe('baseFind()', () => {
it('finds all elements of a selector in the document', () => {
- const div = SVG('<div>', true).id('foo').addTo(container)
- const span = SVG('<span>', true).addClass('bar').addTo(div)
- const span2 = SVG('<span>', true).addTo(div)
+ const div = SVG('<div />', true).id('foo').addTo(container)
+ const span = SVG('<span />', true).addClass('bar').addTo(div)
+ const span2 = SVG('<span />', true).addTo(div)
expect(find('#canvas').map(el => el.node)).toEqual([ container ])
expect(find('span')).toEqual([ span, span2 ])
})
it('finds all elements of a selector scoped to an element', () => {
- const div = SVG('<div>', true).id('foo').addTo(container)
+ const div = SVG('<div />', true).id('foo').addTo(container)
expect(find('#canvas', getWindow().document)[0].node).toBe(container)
expect(find('#foo', container)).toEqual([ div ])
})
it('creates an element in the html namespace from passed html string', () => {
- const div = makeInstance('<div>', true)
+ const div = makeInstance('<div />', true)
expect(adoptSpy).toHaveBeenCalledWith(any(Node))
expect(adoptSpy).toHaveBeenCalledWith(objectContaining({ nodeName: 'DIV', namespaceURI: 'http://www.w3.org/1999/xhtml' }))