import { withMockConsoleLog } from "./test-util"; import { convertSvgMarkupToSymbolData } from "./vocabulary-builder"; const CIRCLE = ``; function arrow(color: string) { return ``; } describe("convertSvgMarkupToSymbolData()", () => { it("works with SVGs that just have a path and no specs", () => { expect( convertSvgMarkupToSymbolData("blarg.svg", `${CIRCLE}`) ).toMatchSnapshot(); }); it("ignores empty layers", () => { const sd1 = convertSvgMarkupToSymbolData( "blarg.svg", `${CIRCLE}` ); const sd2 = convertSvgMarkupToSymbolData( "blarg.svg", `${CIRCLE}` ); expect(sd1).toEqual(sd2); }); it("processes specs", () => { const result = convertSvgMarkupToSymbolData( "blarg.svg", `${CIRCLE}${arrow("#ff0000")}` ); expect(result.specs?.anchor).toHaveLength(1); expect(result.specs).toMatchSnapshot(); }); it("ignores colors in specs it doesn't understand", () => { withMockConsoleLog((mockLog) => { const result = convertSvgMarkupToSymbolData( "blarg.svg", `${CIRCLE}${arrow("#f1f1f1")}` ); expect(result.specs).toEqual({}); expect(mockLog).toHaveBeenCalledWith( 'Not sure what to do with specs path with fill "#f1f1f1", ignoring it.' ); }); }); });