import { Path } from '../shapes/Path'; import { Rect } from '../shapes/Rect'; import { loadSVGFromString } from './loadSVGFromString'; describe('loadSVGFromString', () => { it('returns successful parse of svg with use tag containing bad reference', async () => { // in this case, ignore bad use but still load rest of svg const str = ` `; const parsedSvg = await loadSVGFromString(str); expect(parsedSvg.objects[0]).not.toBeNull(); if (parsedSvg.objects[0] !== null) { expect(parsedSvg.objects[0].isType('Rect')).toBe(true); } }); it('returns successful parse of svg with use tag containing bad clip-path', async () => { // in this case, load svg but ignore clip-path attribute in const str = ` `; const parsedSvg = await loadSVGFromString(str); if (parsedSvg.objects[0] !== null) { expect(parsedSvg.objects[0] instanceof Path).toBe(true); } }); it('returns successful parse of svg with id starting with number', async () => { const str = ` `; const parsedSvg = await loadSVGFromString(str); expect( parsedSvg.objects[0] instanceof Rect && (parsedSvg.objects[0] as Rect & { id: string }).id, ).toBe('123xyz'); }); });