- Breaking change: Rename config file to svgedit-config-iife.js (or for the module version, svgedit-config-es.js);
also expect one directory higher; incorporates #207 (@iuyiuy) - Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons) - Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for better namespacing); incorporates #207 (@iuyiuy) - Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine) - Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed - Fix: Update Atom feed reference in HTML - Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes - Enhancement: Move config-sample.js out of `editor` directory - Enhancement: For `callback`-style extensions, also provide config object; add following to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml - Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel; make Node build routine for converting modular source to non-modular, use `loadStylesheets` for modular stylehsheet defining (but parallel loading); - Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default). - Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines - Refactoring: Avoid embedded API adding inline JavaScript listener - Refactoring: Move layers and context code to `draw.js` - Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js` - Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing) - Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency - Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules - Refactoring: Further avoidance of quotes on properties (as possible) - Refactoring: Use `class` in place of functions where intended as classes - Refactoring: Consistency and granularity in extensions imports - Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions - Testing: Add node-static for automating (and accessing out-of-directory contents) - Testing: Avoid HTML attributes for styling - Testing: Add npm `test` script - Testing: Comment out unused jQuery SVG test - Testing: Add test1 and svgutils_performance_test to all tests page - Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class - npm: Update devDeps - npm: Add html modules and config build to test script
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
/* eslint-env qunit */
|
||||
/* globals svgedit, equals */
|
||||
import * as units from '../editor/units.js';
|
||||
|
||||
// log function
|
||||
QUnit.log = function (details) {
|
||||
QUnit.log(function (details) {
|
||||
if (window.console && window.console.log) {
|
||||
window.console.log(details.result + ' :: ' + details.message);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
function setUp () {
|
||||
svgedit.units.init({
|
||||
units.init({
|
||||
getBaseUnit () { return 'cm'; },
|
||||
getHeight () { return 600; },
|
||||
getWidth () { return 800; },
|
||||
@@ -18,64 +18,64 @@ function setUp () {
|
||||
});
|
||||
}
|
||||
|
||||
test('Test svgedit.units package', function () {
|
||||
expect(2);
|
||||
ok(svgedit.units);
|
||||
equals(typeof svgedit.units, typeof {});
|
||||
QUnit.test('Test svgedit.units package', function (assert) {
|
||||
assert.expect(2);
|
||||
assert.ok(units);
|
||||
assert.equal(typeof units, typeof {});
|
||||
});
|
||||
|
||||
test('Test svgedit.units.shortFloat()', function () {
|
||||
expect(7);
|
||||
QUnit.test('Test svgedit.units.shortFloat()', function (assert) {
|
||||
assert.expect(7);
|
||||
|
||||
setUp();
|
||||
|
||||
ok(svgedit.units.shortFloat);
|
||||
equals(typeof svgedit.units.shortFloat, typeof function () {});
|
||||
assert.ok(units.shortFloat);
|
||||
assert.equal(typeof units.shortFloat, typeof function () {});
|
||||
|
||||
const {shortFloat} = svgedit.units;
|
||||
equals(shortFloat(0.00000001), 0);
|
||||
equals(shortFloat(1), 1);
|
||||
equals(shortFloat(3.45678), 3.4568);
|
||||
equals(shortFloat(1.23443), 1.2344);
|
||||
equals(shortFloat(1.23455), 1.2346);
|
||||
const {shortFloat} = units;
|
||||
assert.equal(shortFloat(0.00000001), 0);
|
||||
assert.equal(shortFloat(1), 1);
|
||||
assert.equal(shortFloat(3.45678), 3.4568);
|
||||
assert.equal(shortFloat(1.23443), 1.2344);
|
||||
assert.equal(shortFloat(1.23455), 1.2346);
|
||||
});
|
||||
|
||||
test('Test svgedit.units.isValidUnit()', function () {
|
||||
expect(18);
|
||||
QUnit.test('Test svgedit.units.isValidUnit()', function (assert) {
|
||||
assert.expect(18);
|
||||
|
||||
setUp();
|
||||
|
||||
ok(svgedit.units.isValidUnit);
|
||||
equals(typeof svgedit.units.isValidUnit, typeof function () {});
|
||||
assert.ok(units.isValidUnit);
|
||||
assert.equal(typeof units.isValidUnit, typeof function () {});
|
||||
|
||||
const {isValidUnit} = svgedit.units;
|
||||
ok(isValidUnit('0'));
|
||||
ok(isValidUnit('1'));
|
||||
ok(isValidUnit('1.1'));
|
||||
ok(isValidUnit('-1.1'));
|
||||
ok(isValidUnit('.6mm'));
|
||||
ok(isValidUnit('-.6cm'));
|
||||
ok(isValidUnit('6000in'));
|
||||
ok(isValidUnit('6px'));
|
||||
ok(isValidUnit('6.3pc'));
|
||||
ok(isValidUnit('-0.4em'));
|
||||
ok(isValidUnit('-0.ex'));
|
||||
ok(isValidUnit('40.123%'));
|
||||
const {isValidUnit} = units;
|
||||
assert.ok(isValidUnit('0'));
|
||||
assert.ok(isValidUnit('1'));
|
||||
assert.ok(isValidUnit('1.1'));
|
||||
assert.ok(isValidUnit('-1.1'));
|
||||
assert.ok(isValidUnit('.6mm'));
|
||||
assert.ok(isValidUnit('-.6cm'));
|
||||
assert.ok(isValidUnit('6000in'));
|
||||
assert.ok(isValidUnit('6px'));
|
||||
assert.ok(isValidUnit('6.3pc'));
|
||||
assert.ok(isValidUnit('-0.4em'));
|
||||
assert.ok(isValidUnit('-0.ex'));
|
||||
assert.ok(isValidUnit('40.123%'));
|
||||
|
||||
equals(isValidUnit('id', 'uniqueId', document.getElementById('uniqueId')), true);
|
||||
equals(isValidUnit('id', 'newId', document.getElementById('uniqueId')), true);
|
||||
equals(isValidUnit('id', 'uniqueId'), false);
|
||||
equals(isValidUnit('id', 'uniqueId', document.getElementById('nonUniqueId')), false);
|
||||
assert.equal(isValidUnit('id', 'uniqueId', document.getElementById('uniqueId')), true);
|
||||
assert.equal(isValidUnit('id', 'newId', document.getElementById('uniqueId')), true);
|
||||
assert.equal(isValidUnit('id', 'uniqueId'), false);
|
||||
assert.equal(isValidUnit('id', 'uniqueId', document.getElementById('nonUniqueId')), false);
|
||||
});
|
||||
|
||||
test('Test svgedit.units.convertUnit()', function () {
|
||||
expect(4);
|
||||
QUnit.test('Test svgedit.units.convertUnit()', function (assert) {
|
||||
assert.expect(4);
|
||||
|
||||
setUp();
|
||||
|
||||
ok(svgedit.units.convertUnit);
|
||||
equals(typeof svgedit.units.convertUnit, typeof function () {});
|
||||
assert.ok(units.convertUnit);
|
||||
assert.equal(typeof units.convertUnit, typeof function () {});
|
||||
// cm in default setup
|
||||
equals(svgedit.units.convertUnit(42), 1.1113);
|
||||
equals(svgedit.units.convertUnit(42, 'px'), 42);
|
||||
assert.equal(units.convertUnit(42), 1.1113);
|
||||
assert.equal(units.convertUnit(42, 'px'), 42);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user