mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-30 01:24:55 +01:00
cb2ca74a20
Core-js, web2d and mindplot working baseline * fix .eslintignore remove Raphael dependency * Fix to avoid crashes in _plotPrediction whitout Raphael * Fix minplot basic code inspections * Fix last inspections errors * Inital refactor copying files * Clean up. * Fix web2d cyclic dependencies remove only-warn eslint plugin set import/no-extraneous-dependencies to warn (incorrectly complaining about root package) * Fix web2d Point references (no need to assign it to core) Fix web2d imports in mindplot and update Point refs * Merge 'feature/mindplot_tests' into web2d-coreJS-solutions * mindplot fixes and add viewmode.html playground setup playground config to run the map-render examples fix mindplot components export mootools Static was not working so refactored it fix some references to _peer fix messages __bundle undefined add web2d missing export: Image downgrade cypress to avoid SIGSEGV error Approved-by: Paulo Veiga
78 lines
3.9 KiB
JavaScript
78 lines
3.9 KiB
JavaScript
describe('Symmetric Test Suite', () => {
|
|
it('symmetricTest', () => {
|
|
const position = { x: 0, y: 0 };
|
|
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
|
|
|
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
|
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
|
manager.addNode(3, TestSuite.NODE_SIZE, position);
|
|
manager.addNode(4, TestSuite.NODE_SIZE, position);
|
|
manager.addNode(5, TestSuite.NODE_SIZE, position);
|
|
manager.addNode(6, TestSuite.NODE_SIZE, position);
|
|
manager.addNode(7, TestSuite.NODE_SIZE, position);
|
|
manager.addNode(8, TestSuite.NODE_SIZE, position);
|
|
manager.addNode(9, TestSuite.NODE_SIZE, position);
|
|
manager.addNode(10, TestSuite.NODE_SIZE, position);
|
|
manager.addNode(11, TestSuite.NODE_SIZE, position);
|
|
manager.addNode(12, TestSuite.NODE_SIZE, position);
|
|
manager.addNode(13, TestSuite.NODE_SIZE, position);
|
|
manager.addNode(14, TestSuite.NODE_SIZE, position);
|
|
manager.connectNode(0, 14, 0);
|
|
manager.connectNode(14, 13, 0);
|
|
manager.connectNode(13, 1, 0);
|
|
manager.connectNode(13, 2, 1);
|
|
manager.connectNode(13, 3, 2);
|
|
manager.connectNode(13, 4, 3);
|
|
manager.connectNode(13, 5, 4);
|
|
manager.connectNode(1, 6, 0);
|
|
manager.connectNode(1, 7, 1);
|
|
manager.connectNode(7, 8, 0);
|
|
manager.connectNode(8, 9, 0);
|
|
manager.connectNode(5, 10, 0);
|
|
manager.connectNode(6, 11, 0);
|
|
manager.connectNode(6, 12, 1);
|
|
|
|
manager.layout();
|
|
|
|
// All nodes should be positioned symmetrically with respect to their common ancestors
|
|
expect(manager.find(14).getPosition().y).toEqual(manager.find(13).getPosition().y);
|
|
expect(manager.find(5).getPosition().y).toEqual(manager.find(10).getPosition().y);
|
|
expect(manager.find(11).getPosition().y - manager.find(6).getPosition().y).toEqual(-(manager.find(12).getPosition().y - manager.find(6).getPosition().y));
|
|
expect(manager.find(8).getPosition().y - manager.find(1).getPosition().y).toEqual(-(manager.find(11).getPosition().y - manager.find(1).getPosition().y));
|
|
expect(manager.find(9).getPosition().y - manager.find(1).getPosition().y).toEqual(-(manager.find(11).getPosition().y - manager.find(1).getPosition().y));
|
|
});
|
|
|
|
it('symmetricDragPredictTest', () => {
|
|
const position = { x: 0, y: 0 };
|
|
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
|
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 1);
|
|
manager.addNode(2, TestSuite.NODE_SIZE, position).connectNode(1, 2, 0);
|
|
manager.layout();
|
|
|
|
const prediction1a = manager.predict(1, 2, { x: -250, y: -20 });
|
|
expect(prediction1a.position.x).toEqual(manager.find(2).getPosition().x);
|
|
expect(prediction1a.position.y).toEqual(manager.find(2).getPosition().y);
|
|
expect(prediction1a.order).toEqual(manager.find(2).getOrder());
|
|
|
|
const prediction1b = manager.predict(1, 2, { x: -250, y: 20 });
|
|
expect(prediction1b.position.x).toEqual(manager.find(2).getPosition().x);
|
|
expect(prediction1b.position.y).toEqual(manager.find(2).getPosition().y);
|
|
expect(prediction1b.order).toEqual(manager.find(2).getOrder());
|
|
|
|
const prediction1c = manager.predict(0, 2, { x: -100, y: -20 });
|
|
expect(prediction1c.position.x).toEqual(manager.find(1).getPosition().x);
|
|
expect(prediction1c.position.y).toBeLessThan(manager.find(1).getPosition().y);
|
|
expect(prediction1c.order).toEqual(manager.find(1).getOrder());
|
|
|
|
const prediction1d = manager.predict(0, 2, { x: -100, y: 20 });
|
|
expect(prediction1d.position.x).toEqual(manager.find(1).getPosition().x);
|
|
expect(prediction1d.position.y).toBeGreaterThan(manager.find(1).getPosition().y);
|
|
expect(prediction1d.order).toEqual(3);
|
|
|
|
const prediction1e = manager.predict(1, 2, { x: -250, y: 0 });
|
|
expect(prediction1e.position.x).toEqual(manager.find(2).getPosition().x);
|
|
expect(prediction1e.position.y).toEqual(manager.find(2).getPosition().y);
|
|
expect(prediction1e.order).toEqual(manager.find(2).getOrder());
|
|
});
|
|
});
|