move to standard linter for simpler configuration

This commit is contained in:
JFH
2021-12-28 11:02:29 -03:00
parent 258e2bd6a1
commit fdcfc8a253
251 changed files with 19760 additions and 19935 deletions

View File

@@ -1,37 +1,37 @@
import * as select from '../../../instrumented/svgcanvas/select.js';
import { NS } from '../../../instrumented/svgcanvas/namespaces.js';
import * as select from '../../../instrumented/svgcanvas/select.js'
import { NS } from '../../../instrumented/svgcanvas/namespaces.js'
describe('select', function () {
const sandbox = document.createElement('div');
sandbox.id = 'sandbox';
const sandbox = document.createElement('div')
sandbox.id = 'sandbox'
let svgroot;
let svgContent;
let svgroot
let svgContent
const mockConfig = {
dimensions: [ 640, 480 ]
};
dimensions: [640, 480]
}
const dataStorage = {
_storage: new WeakMap(),
put: function (element, key, obj) {
if (!this._storage.has(element)) {
this._storage.set(element, new Map());
this._storage.set(element, new Map())
}
this._storage.get(element).set(key, obj);
this._storage.get(element).set(key, obj)
},
get: function (element, key) {
return this._storage.get(element).get(key);
return this._storage.get(element).get(key)
},
has: function (element, key) {
return this._storage.has(element) && this._storage.get(element).has(key);
return this._storage.has(element) && this._storage.get(element).has(key)
},
remove: function (element, key) {
const ret = this._storage.get(element).delete(key);
const ret = this._storage.get(element).delete(key)
if (!this._storage.get(element).size === 0) {
this._storage.delete(element);
this._storage.delete(element)
}
return ret;
return ret
}
};
}
/**
* @implements {module:select.SVGFactory}
@@ -39,16 +39,16 @@ describe('select', function () {
const mockSvgCanvas = {
curConfig: mockConfig,
createSVGElement (jsonMap) {
const elem = document.createElementNS(NS.SVG, jsonMap.element);
Object.entries(jsonMap.attr).forEach(([ attr, value ]) => {
elem.setAttribute(attr, value);
});
return elem;
const elem = document.createElementNS(NS.SVG, jsonMap.element)
Object.entries(jsonMap.attr).forEach(([attr, value]) => {
elem.setAttribute(attr, value)
})
return elem
},
getSvgRoot () { return svgroot; },
getSvgContent () { return svgContent; },
getDataStorage () { return dataStorage; }
};
getSvgRoot () { return svgroot },
getSvgContent () { return svgContent },
getDataStorage () { return dataStorage }
}
/**
* Potentially reusable test set-up.
@@ -58,13 +58,13 @@ describe('select', function () {
svgroot = mockSvgCanvas.createSVGElement({
element: 'svg',
attr: { id: 'svgroot' }
});
})
svgContent = mockSvgCanvas.createSVGElement({
element: 'svg',
attr: { id: 'svgcontent' }
});
})
svgroot.append(svgContent);
svgroot.append(svgContent)
/* const rect = */ svgContent.append(
mockSvgCanvas.createSVGElement({
element: 'rect',
@@ -76,9 +76,9 @@ describe('select', function () {
height: '100'
}
})
);
sandbox.append(svgroot);
});
)
sandbox.append(svgroot)
})
/*
function setUpWithInit () {
@@ -92,61 +92,61 @@ describe('select', function () {
*/
afterEach(() => {
while (sandbox.hasChildNodes()) {
sandbox.firstChild.remove();
sandbox.firstChild.remove()
}
});
})
it('Test svgedit.select package', function () {
assert.ok(select);
assert.ok(select.Selector);
assert.ok(select.SelectorManager);
assert.ok(select.init);
assert.ok(select.getSelectorManager);
assert.equal(typeof select, typeof {});
assert.equal(typeof select.Selector, typeof function () { /* empty fn */ });
assert.equal(typeof select.SelectorManager, typeof function () { /* empty fn */ });
assert.equal(typeof select.init, typeof function () { /* empty fn */ });
assert.equal(typeof select.getSelectorManager, typeof function () { /* empty fn */ });
});
assert.ok(select)
assert.ok(select.Selector)
assert.ok(select.SelectorManager)
assert.ok(select.init)
assert.ok(select.getSelectorManager)
assert.equal(typeof select, typeof {})
assert.equal(typeof select.Selector, typeof function () { /* empty fn */ })
assert.equal(typeof select.SelectorManager, typeof function () { /* empty fn */ })
assert.equal(typeof select.init, typeof function () { /* empty fn */ })
assert.equal(typeof select.getSelectorManager, typeof function () { /* empty fn */ })
})
it('Test Selector DOM structure', function () {
assert.ok(svgroot);
assert.ok(svgroot.hasChildNodes());
assert.ok(svgroot)
assert.ok(svgroot.hasChildNodes())
// Verify non-existence of Selector DOM nodes
assert.equal(svgroot.childNodes.length, 1);
assert.equal(svgroot.childNodes.item(0), svgContent);
assert.ok(!svgroot.querySelector('#selectorParentGroup'));
assert.equal(svgroot.childNodes.length, 1)
assert.equal(svgroot.childNodes.item(0), svgContent)
assert.ok(!svgroot.querySelector('#selectorParentGroup'))
select.init(mockSvgCanvas);
select.init(mockSvgCanvas)
assert.equal(svgroot.childNodes.length, 3);
assert.equal(svgroot.childNodes.length, 3)
// Verify existence of canvas background.
const cb = svgroot.childNodes.item(0);
assert.ok(cb);
assert.equal(cb.id, 'canvasBackground');
const cb = svgroot.childNodes.item(0)
assert.ok(cb)
assert.equal(cb.id, 'canvasBackground')
assert.ok(svgroot.childNodes.item(1));
assert.equal(svgroot.childNodes.item(1), svgContent);
assert.ok(svgroot.childNodes.item(1))
assert.equal(svgroot.childNodes.item(1), svgContent)
// Verify existence of selectorParentGroup.
const spg = svgroot.childNodes.item(2);
assert.ok(spg);
assert.equal(svgroot.querySelector('#selectorParentGroup'), spg);
assert.equal(spg.id, 'selectorParentGroup');
assert.equal(spg.tagName, 'g');
const spg = svgroot.childNodes.item(2)
assert.ok(spg)
assert.equal(svgroot.querySelector('#selectorParentGroup'), spg)
assert.equal(spg.id, 'selectorParentGroup')
assert.equal(spg.tagName, 'g')
// Verify existence of all grip elements.
assert.ok(spg.querySelector('#selectorGrip_resize_nw'));
assert.ok(spg.querySelector('#selectorGrip_resize_n'));
assert.ok(spg.querySelector('#selectorGrip_resize_ne'));
assert.ok(spg.querySelector('#selectorGrip_resize_e'));
assert.ok(spg.querySelector('#selectorGrip_resize_se'));
assert.ok(spg.querySelector('#selectorGrip_resize_s'));
assert.ok(spg.querySelector('#selectorGrip_resize_sw'));
assert.ok(spg.querySelector('#selectorGrip_resize_w'));
assert.ok(spg.querySelector('#selectorGrip_rotateconnector'));
assert.ok(spg.querySelector('#selectorGrip_rotate'));
});
});
assert.ok(spg.querySelector('#selectorGrip_resize_nw'))
assert.ok(spg.querySelector('#selectorGrip_resize_n'))
assert.ok(spg.querySelector('#selectorGrip_resize_ne'))
assert.ok(spg.querySelector('#selectorGrip_resize_e'))
assert.ok(spg.querySelector('#selectorGrip_resize_se'))
assert.ok(spg.querySelector('#selectorGrip_resize_s'))
assert.ok(spg.querySelector('#selectorGrip_resize_sw'))
assert.ok(spg.querySelector('#selectorGrip_resize_w'))
assert.ok(spg.querySelector('#selectorGrip_rotateconnector'))
assert.ok(spg.querySelector('#selectorGrip_rotate'))
})
})