svg-pathdata
Version:
Manipulate SVG path data (path[d] attribute content) simply and efficiently.
30 lines • 1.77 kB
JavaScript
import { describe, test, expect } from '@jest/globals';
import { SVGPathData } from '../index.js';
describe("Matrix transformation should be the same than it's equivalent transformation", () => {
test('should fail with bad args', () => {
expect(() => new SVGPathData('m20,30l10,10z')
.matrix(...[])
.encode()).toThrow(new Error('assertNumbers arguments[0] is not a number. undefined == typeof undefined'));
expect(() => new SVGPathData('m20,30l10,10z')
.matrix(...[1])
.encode()).toThrow(new Error('assertNumbers arguments[1] is not a number. undefined == typeof undefined'));
expect(() => new SVGPathData('m20,30l10,10z')
.matrix(...[1, 1])
.encode()).toThrow(new Error('assertNumbers arguments[2] is not a number. undefined == typeof undefined'));
expect(() => new SVGPathData('m20,30l10,10z')
.matrix(...[1, 1, 1])
.encode()).toThrow(new Error('assertNumbers arguments[3] is not a number. undefined == typeof undefined'));
expect(() => new SVGPathData('m20,30l10,10z')
.matrix(...[1, 1, 1, 1])
.encode()).toThrow(new Error('assertNumbers arguments[4] is not a number. undefined == typeof undefined'));
expect(() => new SVGPathData('m20,30l10,10z')
.matrix(...[1, 1, 1, 1, 1])
.encode()).toThrow(new Error('assertNumbers arguments[5] is not a number. undefined == typeof undefined'));
});
test('for scale', () => {
expect(new SVGPathData('m20 30c0 0 10 20 15 30z').scale(10, 10).encode()).toEqual(new SVGPathData('m20 30c0 0 10 20 15 30z')
.matrix(10, 0, 0, 10, 0, 0)
.encode());
});
});
//# sourceMappingURL=matrix.test.js.map