Testing: add testing for convertPath function

master
cuixiping 2020-01-16 14:20:19 +08:00
parent 6ff0d9d58f
commit e69fd11766
1 changed files with 16 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import '../../../instrumented/svgpathseg.js';
import {NS} from '../../../instrumented/namespaces.js'; import {NS} from '../../../instrumented/namespaces.js';
import * as utilities from '../../../instrumented/utilities.js'; import * as utilities from '../../../instrumented/utilities.js';
import * as pathModule from '../../../instrumented/path.js'; import * as pathModule from '../../../instrumented/path.js';
import {init as unitsInit} from '../../../instrumented/units.js';
describe('path', function () { describe('path', function () {
/** /**
@ -164,4 +165,19 @@ describe('path', function () {
assert.equal(path.pathSegList.getItem(1).x, 15); assert.equal(path.pathSegList.getItem(1).x, 15);
assert.equal(path.pathSegList.getItem(1).y, 16); assert.equal(path.pathSegList.getItem(1).y, 16);
}); });
it('Test svgedit.path.convertPath', function () {
unitsInit({
getRoundDigits () { return 5; }
});
const path = document.createElementNS(NS.SVG, 'path');
path.setAttribute('d', 'M40,55h20v20');
const abs = pathModule.convertPath(path);
assert.equal(abs, 'M40,55L60,55L60,75');
const rel = pathModule.convertPath(path, true);
assert.equal(rel, 'm40,55l20,0l0,20');
});
}); });