Files
enviPy-bayer/static/js/ketcher2/node_modules/svg-pathdata/tests/transformer.mocha.js
2025-06-23 20:13:54 +02:00

45 lines
1.2 KiB
JavaScript

var assert = (
global && global.chai
? global.chai.assert
: require('chai').assert
)
, SVGPathData = (
global && global.SVGPathData
? global.SVGPathData
: require(__dirname + '/../src/SVGPathData.js')
)
;
describe("SVGPathDataTransformer", function() {
it("should fail with bad args", function() {
assert.throws(function() {
new SVGPathData.Transformer();
}, 'Please provide a transform callback to receive commands.');
});
it("should fail with bad transform function", function() {
assert.throws(function() {
new SVGPathData.Transformer(function() {});
}, 'Please provide a valid transform (returning a function).');
});
it("should still work when the new operator is forgotten", function() {
assert.doesNotThrow(function() {
SVGPathData.Transformer(SVGPathData.Transformer.SCALE, 1, 1);
});
});
it("should work in streaming mode", function() {
var encoder = new SVGPathData.Transformer(SVGPathData.Transformer.SCALE, 1, 1);
encoder.write({
type: SVGPathData.Parser.LINE_TO,
relative: true,
x: 10,
y: 10
});
encoder.end();
});
});