import { convertSvgMarkupToSymbolData } from "./vocabulary-builder";
const CIRCLE = ``;
function arrow(color: string) {
return ``;
}
function withMockConsoleLog(fn: (mock: jest.Mock) => void) {
const originalLog = console.log;
const mockLog = jest.fn();
console.log = mockLog;
try {
fn(mockLog);
} finally {
console.log = originalLog;
}
}
describe("convertSvgMarkupToSymbolData()", () => {
it("works with SVGs that just have a path and no specs", () => {
expect(
convertSvgMarkupToSymbolData("blarg.svg", ``)
).toMatchSnapshot();
});
it("ignores empty layers", () => {
const sd1 = convertSvgMarkupToSymbolData(
"blarg.svg",
``
);
const sd2 = convertSvgMarkupToSymbolData(
"blarg.svg",
``
);
expect(sd1).toEqual(sd2);
});
it("processes specs", () => {
const result = convertSvgMarkupToSymbolData(
"blarg.svg",
``
);
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",
``
);
expect(result.specs).toEqual({});
expect(mockLog).toHaveBeenCalledWith(
'Not sure what to do with specs path with fill "#f1f1f1", ignoring it.'
);
});
});
});