Enable nullable check.

This commit is contained in:
Paulo Gustavo Veiga 2022-12-10 11:15:36 -08:00
parent 132fb97078
commit 4ae3e07537
8 changed files with 107 additions and 84 deletions

View File

@ -1,3 +1,21 @@
/*
* Copyright [2021] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert } from '@wisemapping/core-js';
import Designer from './Designer'; import Designer from './Designer';
import buildDesigner from './DesignerBuilder'; import buildDesigner from './DesignerBuilder';
import DesignerOptionsBuilder from './DesignerOptionsBuilder'; import DesignerOptionsBuilder from './DesignerOptionsBuilder';
@ -65,11 +83,15 @@ class MindplotWebComponent extends HTMLElement {
const persistenceManager = persistence || new LocalStorageManager('map.xml', false, false); const persistenceManager = persistence || new LocalStorageManager('map.xml', false, false);
const mode = editorRenderMode || 'viewonly'; const mode = editorRenderMode || 'viewonly';
const mindplodElem = this._shadowRoot.getElementById('mindplot');
$assert(mindplodElem, 'Root mindplot element could not be loaded');
const options = DesignerOptionsBuilder.buildOptions({ const options = DesignerOptionsBuilder.buildOptions({
persistenceManager, persistenceManager,
mode, mode,
widgetManager, widgetManager,
divContainer: this._shadowRoot.getElementById('mindplot'), divContainer: mindplodElem!,
container: 'mindplot', container: 'mindplot',
zoom: zoom ? Number.parseFloat(zoom) : 1, zoom: zoom ? Number.parseFloat(zoom) : 1,
locale: locale || 'en', locale: locale || 'en',

View File

@ -4,7 +4,7 @@ export default class FreemindIconConverter {
private static freeIdToIcon: Map<string, SvgIconModel> = new Map<string, SvgIconModel>(); private static freeIdToIcon: Map<string, SvgIconModel> = new Map<string, SvgIconModel>();
public static toWiseId(iconId: string): number | null { public static toWiseId(iconId: string): number | null {
const result: SvgIconModel = this.freeIdToIcon.get(iconId); const result: SvgIconModel = this.freeIdToIcon.get(iconId)!;
return result ? result.getId() : null; return result ? result.getId() : null;
} }
} }

View File

@ -70,7 +70,7 @@ export default class FreemindImporter extends Importer {
this.convertNodeProperties(freeNode, wiseTopic, true); this.convertNodeProperties(freeNode, wiseTopic, true);
this.nodesmap.set(freeNode.getId(), wiseTopic); this.nodesmap.set(freeNode.getId()!, wiseTopic);
this.convertChildNodes(freeNode, wiseTopic, this.mindmap, 1); this.convertChildNodes(freeNode, wiseTopic, this.mindmap, 1);
this.addRelationship(this.mindmap); this.addRelationship(this.mindmap);

View File

@ -135,15 +135,17 @@ class BalancedSorter extends AbstractBasicSorter {
detach(treeSet: RootedTreeSet, node: Node): void { detach(treeSet: RootedTreeSet, node: Node): void {
const parent = treeSet.getParent(node); const parent = treeSet.getParent(node);
// Filter nodes on one side.. if (parent) {
const children = this._getChildrenForOrder(parent, treeSet, node.getOrder()); // Filter nodes on one side..
const children = this._getChildrenForOrder(parent, treeSet, node.getOrder());
children.forEach((child) => { children.forEach((child) => {
if (child.getOrder() > node.getOrder()) { if (child.getOrder() > node.getOrder()) {
child.setOrder(child.getOrder() - 2); child.setOrder(child.getOrder() - 2);
} }
}); });
node.setOrder(node.getOrder() % 2 === 0 ? 0 : 1); node.setOrder(node.getOrder() % 2 === 0 ? 0 : 1);
}
} }
computeOffsets(treeSet: RootedTreeSet, node: Node) { computeOffsets(treeSet: RootedTreeSet, node: Node) {

View File

@ -24,7 +24,7 @@ class Node {
private _id: number; private _id: number;
// eslint-disable-next-line no-use-before-define // eslint-disable-next-line no-use-before-define
_parent: Node; _parent: Node | null;
private _sorter: ChildrenSorterStrategy; private _sorter: ChildrenSorterStrategy;

View File

@ -94,7 +94,7 @@ class RootedTreeSet {
const node = this.find(nodeId); const node = this.find(nodeId);
$assert(node._parent, 'Node is not connected'); $assert(node._parent, 'Node is not connected');
node._parent._children = node._parent._children.filter((n) => node !== n); node._parent!._children = node._parent!._children.filter((n) => node !== n);
this._rootNodes.push(node); this._rootNodes.push(node);
node._parent = null; node._parent = null;
} }
@ -160,7 +160,7 @@ class RootedTreeSet {
getRootNode(node: Node) { getRootNode(node: Node) {
$assert(node, 'node cannot be null'); $assert(node, 'node cannot be null');
const parent = this.getParent(node); const parent = this.getParent(node);
if ($defined(parent)) { if (parent) {
return this.getRootNode(parent); return this.getRootNode(parent);
} }
@ -176,7 +176,7 @@ class RootedTreeSet {
return this._getAncestors(this.getParent(node), []); return this._getAncestors(this.getParent(node), []);
} }
_getAncestors(node: Node, ancestors: Node[]) { private _getAncestors(node: Node | null, ancestors: Node[]) {
const result = ancestors; const result = ancestors;
if (node) { if (node) {
result.push(node); result.push(node);
@ -192,7 +192,7 @@ class RootedTreeSet {
*/ */
getSiblings(node: Node): Node[] { getSiblings(node: Node): Node[] {
$assert(node, 'node cannot be null'); $assert(node, 'node cannot be null');
if (!$defined(node._parent)) { if (!node._parent) {
return []; return [];
} }
const siblings = node._parent._children.filter((child) => child !== node); const siblings = node._parent._children.filter((child) => child !== node);
@ -241,7 +241,7 @@ class RootedTreeSet {
* @throws will throw an error if node is null or undefined * @throws will throw an error if node is null or undefined
* @return parent * @return parent
*/ */
getParent(node: Node): Node { getParent(node: Node): Node | null {
$assert(node, 'node cannot be null'); $assert(node, 'node cannot be null');
return node._parent; return node._parent;
} }
@ -373,7 +373,7 @@ class RootedTreeSet {
getSiblingsInVerticalDirection(node: Node, yOffset: number): Node[] { getSiblingsInVerticalDirection(node: Node, yOffset: number): Node[] {
// siblings with lower or higher order // siblings with lower or higher order
// (depending on the direction of the offset and on the same side as their parent) // (depending on the direction of the offset and on the same side as their parent)
const parent = this.getParent(node); const parent = this.getParent(node)!;
const siblings = this.getSiblings(node).filter((sibling) => { const siblings = this.getSiblings(node).filter((sibling) => {
const sameSide = const sameSide =
node.getPosition().x > parent.getPosition().x node.getPosition().x > parent.getPosition().x

View File

@ -1,4 +1,3 @@
/* eslint-disable no-console */
/* /*
* Copyright [2021] [wisemapping] * Copyright [2021] [wisemapping]
* *
@ -90,7 +89,7 @@ class BalancedTestSuite extends TestSuite {
manager.plot('testBalanced9', { width: 1000, height: 400 }); manager.plot('testBalanced9', { width: 1000, height: 400 });
// Check orders have shifted accordingly // Check orders have shifted accordingly
$assert(manager.find(5).getOrder() == 6, 'Node 5 should have order 6'); $assert(manager.find(5).getOrder() === 6, 'Node 5 should have order 6');
manager.addNode(14, TestSuite.NODE_SIZE, position); manager.addNode(14, TestSuite.NODE_SIZE, position);
manager.connectNode(0, 14, 5); manager.connectNode(0, 14, 5);
@ -98,7 +97,7 @@ class BalancedTestSuite extends TestSuite {
manager.plot('testBalanced10', { width: 1000, height: 400 }); manager.plot('testBalanced10', { width: 1000, height: 400 });
// Check orders have shifted accordingly // Check orders have shifted accordingly
$assert(manager.find(6).getOrder() == 7, 'Node 6 should have order 7'); $assert(manager.find(6).getOrder() === 7, 'Node 6 should have order 7');
manager.addNode(15, TestSuite.NODE_SIZE, position); manager.addNode(15, TestSuite.NODE_SIZE, position);
manager.connectNode(0, 15, 4); manager.connectNode(0, 15, 4);
@ -106,8 +105,8 @@ class BalancedTestSuite extends TestSuite {
manager.plot('testBalanced11', { width: 1000, height: 400 }); manager.plot('testBalanced11', { width: 1000, height: 400 });
// Check orders have shifted accordingly // Check orders have shifted accordingly
$assert(manager.find(13).getOrder() == 6, 'Node 13 should have order 6'); $assert(manager.find(13).getOrder() === 6, 'Node 13 should have order 6');
$assert(manager.find(5).getOrder() == 8, 'Node 5 should have order 8'); $assert(manager.find(5).getOrder() === 8, 'Node 5 should have order 8');
manager.addNode(16, TestSuite.NODE_SIZE, position); manager.addNode(16, TestSuite.NODE_SIZE, position);
manager.connectNode(0, 16, 25); manager.connectNode(0, 16, 25);
@ -115,7 +114,7 @@ class BalancedTestSuite extends TestSuite {
manager.plot('testBalanced12', { width: 1000, height: 400 }); manager.plot('testBalanced12', { width: 1000, height: 400 });
// Check orders have shifted accordingly // Check orders have shifted accordingly
$assert(manager.find(16).getOrder() == 9, 'Node 16 should have order 9'); $assert(manager.find(16).getOrder() === 9, 'Node 16 should have order 9');
manager.addNode(17, TestSuite.NODE_SIZE, position); manager.addNode(17, TestSuite.NODE_SIZE, position);
manager.addNode(18, TestSuite.NODE_SIZE, position); manager.addNode(18, TestSuite.NODE_SIZE, position);
@ -216,42 +215,42 @@ class BalancedTestSuite extends TestSuite {
this._plotPrediction(graph1, prediction1a); this._plotPrediction(graph1, prediction1a);
$assert( $assert(
prediction1a.position.y < manager.find(1).getPosition().y && prediction1a.position.y < manager.find(1).getPosition().y &&
prediction1a.position.x == manager.find(1).getPosition().x, prediction1a.position.x === manager.find(1).getPosition().x,
'Prediction is incorrectly positioned', 'Prediction is incorrectly positioned',
); );
$assert(prediction1a.order == 0, 'Prediction order should be 0'); $assert(prediction1a.order === 0, 'Prediction order should be 0');
console.log('\tAdded as child of node 0 and dropped at (165, -10):'); console.log('\tAdded as child of node 0 and dropped at (165, -10):');
const prediction1b = manager.predict(0, null, { x: 165, y: -10 }); const prediction1b = manager.predict(0, null, { x: 165, y: -10 });
this._plotPrediction(graph1, prediction1b); this._plotPrediction(graph1, prediction1b);
$assert( $assert(
prediction1b.position.y > manager.find(1).getPosition().y && prediction1b.position.y > manager.find(1).getPosition().y &&
prediction1b.position.y < manager.find(3).getPosition().y && prediction1b.position.y < manager.find(3).getPosition().y &&
prediction1b.position.x == manager.find(1).getPosition().x, prediction1b.position.x === manager.find(1).getPosition().x,
'Prediction is incorrectly positioned', 'Prediction is incorrectly positioned',
); );
$assert(prediction1b.order == 2, 'Prediction order should be 2'); $assert(prediction1b.order === 2, 'Prediction order should be 2');
console.log('\tAdded as child of node 0 and dropped at (145, 15):'); console.log('\tAdded as child of node 0 and dropped at (145, 15):');
const prediction1c = manager.predict(0, null, { x: 145, y: 15 }); const prediction1c = manager.predict(0, null, { x: 145, y: 15 });
this._plotPrediction(graph1, prediction1c); this._plotPrediction(graph1, prediction1c);
$assert( $assert(
prediction1c.position.y > manager.find(3).getPosition().y && prediction1c.position.y > manager.find(3).getPosition().y &&
prediction1c.position.y < manager.find(5).getPosition().y && prediction1c.position.y < manager.find(5).getPosition().y &&
prediction1c.position.x == manager.find(3).getPosition().x, prediction1c.position.x === manager.find(3).getPosition().x,
'Prediction is incorrectly positioned', 'Prediction is incorrectly positioned',
); );
$assert(prediction1c.order == 4, 'Prediction order should be 4'); $assert(prediction1c.order === 4, 'Prediction order should be 4');
console.log('\tAdded as child of node 0 and dropped at (145, 70):'); console.log('\tAdded as child of node 0 and dropped at (145, 70):');
const prediction1d = manager.predict(0, null, { x: 145, y: 70 }); const prediction1d = manager.predict(0, null, { x: 145, y: 70 });
this._plotPrediction(graph1, prediction1d); this._plotPrediction(graph1, prediction1d);
$assert( $assert(
prediction1d.position.y > manager.find(5).getPosition().y && prediction1d.position.y > manager.find(5).getPosition().y &&
prediction1d.position.x == manager.find(5).getPosition().x, prediction1d.position.x === manager.find(5).getPosition().x,
'Prediction is incorrectly positioned', 'Prediction is incorrectly positioned',
); );
$assert(prediction1d.order == 6, 'Prediction order should be 6'); $assert(prediction1d.order === 6, 'Prediction order should be 6');
// Graph 2 // Graph 2
const graph2 = manager.plot('testBalancedPredict2', { width: 1000, height: 400 }); const graph2 = manager.plot('testBalancedPredict2', { width: 1000, height: 400 });
@ -261,31 +260,31 @@ class BalancedTestSuite extends TestSuite {
this._plotPrediction(graph2, prediction2a); this._plotPrediction(graph2, prediction2a);
$assert( $assert(
prediction2a.position.y < manager.find(2).getPosition().y && prediction2a.position.y < manager.find(2).getPosition().y &&
prediction2a.position.x == manager.find(2).getPosition().x, prediction2a.position.x === manager.find(2).getPosition().x,
'Prediction is incorrectly positioned', 'Prediction is incorrectly positioned',
); );
$assert(prediction2a.order == 1, 'Prediction order should be 1'); $assert(prediction2a.order === 1, 'Prediction order should be 1');
console.log('\tAdded as child of node 0 and dropped at (-145, -10):'); console.log('\tAdded as child of node 0 and dropped at (-145, -10):');
const prediction2b = manager.predict(0, null, { x: -145, y: -10 }); const prediction2b = manager.predict(0, null, { x: -145, y: -10 });
this._plotPrediction(graph2, prediction2b); this._plotPrediction(graph2, prediction2b);
$assert( $assert(
prediction2b.position.y > manager.find(2).getPosition().y && prediction2b.position.y > manager.find(2).getPosition().y &&
prediction2b.position.y < manager.find(4).getPosition().y && prediction2b.position.y < manager.find(4).getPosition().y &&
prediction2b.position.x == manager.find(2).getPosition().x, prediction2b.position.x === manager.find(2).getPosition().x,
'Prediction is incorrectly positioned', 'Prediction is incorrectly positioned',
); );
$assert(prediction2b.order == 3, 'Prediction order should be 3'); $assert(prediction2b.order === 3, 'Prediction order should be 3');
console.log('\tAdded as child of node 0 and dropped at (-145, 40):'); console.log('\tAdded as child of node 0 and dropped at (-145, 40):');
const prediction2c = manager.predict(0, null, { x: -145, y: 400 }); const prediction2c = manager.predict(0, null, { x: -145, y: 400 });
this._plotPrediction(graph2, prediction2c); this._plotPrediction(graph2, prediction2c);
$assert( $assert(
prediction2c.position.y > manager.find(4).getPosition().y && prediction2c.position.y > manager.find(4).getPosition().y &&
prediction2c.position.x == manager.find(4).getPosition().x, prediction2c.position.x === manager.find(4).getPosition().x,
'Prediction is incorrectly positioned', 'Prediction is incorrectly positioned',
); );
$assert(prediction2c.order == 5, 'Prediction order should be 5'); $assert(prediction2c.order === 5, 'Prediction order should be 5');
// Graph 3 // Graph 3
console.log('\tPredict nodes added with no position:'); console.log('\tPredict nodes added with no position:');
@ -294,10 +293,10 @@ class BalancedTestSuite extends TestSuite {
this._plotPrediction(graph3, prediction3); this._plotPrediction(graph3, prediction3);
$assert( $assert(
prediction3.position.y > manager.find(4).getPosition().y && prediction3.position.y > manager.find(4).getPosition().y &&
prediction3.position.x == manager.find(4).getPosition().x, prediction3.position.x === manager.find(4).getPosition().x,
'Prediction is incorrectly positioned', 'Prediction is incorrectly positioned',
); );
$assert(prediction3.order == 5, 'Prediction order should be 5'); $assert(prediction3.order === 5, 'Prediction order should be 5');
console.log('\tPredict nodes added with no position:'); console.log('\tPredict nodes added with no position:');
manager.addNode(6, TestSuite.NODE_SIZE, prediction3.position); manager.addNode(6, TestSuite.NODE_SIZE, prediction3.position);
@ -308,10 +307,10 @@ class BalancedTestSuite extends TestSuite {
this._plotPrediction(graph4, prediction4); this._plotPrediction(graph4, prediction4);
$assert( $assert(
prediction4.position.y > manager.find(5).getPosition().y && prediction4.position.y > manager.find(5).getPosition().y &&
prediction4.position.x == manager.find(5).getPosition().x, prediction4.position.x === manager.find(5).getPosition().x,
'Prediction is incorrectly positioned', 'Prediction is incorrectly positioned',
); );
$assert(prediction4.order == 6, 'Prediction order should be 6'); $assert(prediction4.order === 6, 'Prediction order should be 6');
console.log('\tPredict nodes added only a root node:'); console.log('\tPredict nodes added only a root node:');
manager.removeNode(1).removeNode(2).removeNode(3).removeNode(4).removeNode(5); manager.removeNode(1).removeNode(2).removeNode(3).removeNode(4).removeNode(5);
@ -323,16 +322,16 @@ class BalancedTestSuite extends TestSuite {
this._plotPrediction(graph5, prediction5b); this._plotPrediction(graph5, prediction5b);
$assert( $assert(
prediction5a.position.x > manager.find(0).getPosition().x && prediction5a.position.x > manager.find(0).getPosition().x &&
prediction5a.position.y == manager.find(0).getPosition().y, prediction5a.position.y === manager.find(0).getPosition().y,
'Prediction is incorrectly positioned', 'Prediction is incorrectly positioned',
); );
$assert(prediction5a.order == 0, 'Prediction order should be 0'); $assert(prediction5a.order === 0, 'Prediction order should be 0');
$assert( $assert(
prediction5a.position.x == prediction5b.position.x && prediction5a.position.x === prediction5b.position.x &&
prediction5a.position.y == prediction5b.position.y, prediction5a.position.y === prediction5b.position.y,
'Both predictions should be the same', 'Both predictions should be the same',
); );
$assert(prediction5a.order == prediction5b.order, 'Both predictions should be the same'); $assert(prediction5a.order === prediction5b.order, 'Both predictions should be the same');
console.log('OK!\n\n'); console.log('OK!\n\n');
} }
@ -350,24 +349,24 @@ class BalancedTestSuite extends TestSuite {
const prediction1a = manager.predict(0, 1, { x: 50, y: 50 }); const prediction1a = manager.predict(0, 1, { x: 50, y: 50 });
this._plotPrediction(graph1, prediction1a); this._plotPrediction(graph1, prediction1a);
$assert( $assert(
prediction1a.position.x == manager.find(1).getPosition().x && prediction1a.position.x === manager.find(1).getPosition().x &&
prediction1a.position.y == manager.find(1).getPosition().y, prediction1a.position.y === manager.find(1).getPosition().y,
'Prediction position should be the same as node 1', 'Prediction position should be the same as node 1',
); );
$assert( $assert(
prediction1a.order == manager.find(1).getOrder(), prediction1a.order === manager.find(1).getOrder(),
'Prediction order should be the same as node 1', 'Prediction order should be the same as node 1',
); );
const prediction1b = manager.predict(0, 1, { x: 50, y: -50 }); const prediction1b = manager.predict(0, 1, { x: 50, y: -50 });
this._plotPrediction(graph1, prediction1b); this._plotPrediction(graph1, prediction1b);
$assert( $assert(
prediction1b.position.x == manager.find(1).getPosition().x && prediction1b.position.x === manager.find(1).getPosition().x &&
prediction1b.position.y == manager.find(1).getPosition().y, prediction1b.position.y === manager.find(1).getPosition().y,
'Prediction position should be the same as node 1', 'Prediction position should be the same as node 1',
); );
$assert( $assert(
prediction1b.order == manager.find(1).getOrder(), prediction1b.order === manager.find(1).getOrder(),
'Prediction order should be the same as node 1', 'Prediction order should be the same as node 1',
); );
@ -375,19 +374,19 @@ class BalancedTestSuite extends TestSuite {
this._plotPrediction(graph1, prediction1c); this._plotPrediction(graph1, prediction1c);
$assert( $assert(
prediction1c.position.x < manager.find(0).getPosition().x && prediction1c.position.x < manager.find(0).getPosition().x &&
prediction1c.position.y == manager.find(0).getPosition().y, prediction1c.position.y === manager.find(0).getPosition().y,
'Prediction is incorrectly positioned', 'Prediction is incorrectly positioned',
); );
$assert(prediction1c.order == 1, 'Prediction order should be the same as node 1'); $assert(prediction1c.order === 1, 'Prediction order should be the same as node 1');
const prediction1d = manager.predict(0, 1, { x: -50, y: -50 }); const prediction1d = manager.predict(0, 1, { x: -50, y: -50 });
this._plotPrediction(graph1, prediction1d); this._plotPrediction(graph1, prediction1d);
$assert( $assert(
prediction1d.position.x < manager.find(0).getPosition().x && prediction1d.position.x < manager.find(0).getPosition().x &&
prediction1d.position.y == manager.find(0).getPosition().y, prediction1d.position.y === manager.find(0).getPosition().y,
'Prediction is incorrectly positioned', 'Prediction is incorrectly positioned',
); );
$assert(prediction1d.order == 1, 'Prediction order should be the same as node 1'); $assert(prediction1d.order === 1, 'Prediction order should be the same as node 1');
// Graph 2 // Graph 2
manager.disconnectNode(1); manager.disconnectNode(1);
@ -399,41 +398,41 @@ class BalancedTestSuite extends TestSuite {
this._plotPrediction(graph2, prediction2a); this._plotPrediction(graph2, prediction2a);
$assert( $assert(
prediction2a.position.x > manager.find(0).getPosition().x && prediction2a.position.x > manager.find(0).getPosition().x &&
prediction2a.position.y == manager.find(0).getPosition().y, prediction2a.position.y === manager.find(0).getPosition().y,
'Prediction is positioned incorrectly', 'Prediction is positioned incorrectly',
); );
$assert(prediction2a.order == 0, 'Prediction order should be 0'); $assert(prediction2a.order === 0, 'Prediction order should be 0');
const prediction2b = manager.predict(0, 1, { x: 50, y: -50 }); const prediction2b = manager.predict(0, 1, { x: 50, y: -50 });
this._plotPrediction(graph2, prediction2b); this._plotPrediction(graph2, prediction2b);
$assert( $assert(
prediction2b.position.x > manager.find(0).getPosition().x && prediction2b.position.x > manager.find(0).getPosition().x &&
prediction2b.position.y == manager.find(0).getPosition().y, prediction2b.position.y === manager.find(0).getPosition().y,
'Prediction is positioned incorrectly', 'Prediction is positioned incorrectly',
); );
$assert(prediction2b.order == 0, 'Prediction order should be 0'); $assert(prediction2b.order === 0, 'Prediction order should be 0');
const prediction2c = manager.predict(0, 1, { x: -50, y: 50 }); const prediction2c = manager.predict(0, 1, { x: -50, y: 50 });
this._plotPrediction(graph2, prediction2c); this._plotPrediction(graph2, prediction2c);
$assert( $assert(
prediction2c.position.x == manager.find(1).getPosition().x && prediction2c.position.x === manager.find(1).getPosition().x &&
prediction2c.position.y == manager.find(1).getPosition().y, prediction2c.position.y === manager.find(1).getPosition().y,
'Prediction position should be the same as node 1', 'Prediction position should be the same as node 1',
); );
$assert( $assert(
prediction2c.order == manager.find(1).getOrder(), prediction2c.order === manager.find(1).getOrder(),
'Prediction order should be the same as node 1', 'Prediction order should be the same as node 1',
); );
const prediction2d = manager.predict(0, 1, { x: -50, y: -50 }); const prediction2d = manager.predict(0, 1, { x: -50, y: -50 });
this._plotPrediction(graph2, prediction2d); this._plotPrediction(graph2, prediction2d);
$assert( $assert(
prediction2d.position.x == manager.find(1).getPosition().x && prediction2d.position.x === manager.find(1).getPosition().x &&
prediction2d.position.y == manager.find(1).getPosition().y, prediction2d.position.y === manager.find(1).getPosition().y,
'Prediction position should be the same as node 1', 'Prediction position should be the same as node 1',
); );
$assert( $assert(
prediction2d.order == manager.find(1).getOrder(), prediction2d.order === manager.find(1).getOrder(),
'Prediction order should be the same as node 1', 'Prediction order should be the same as node 1',
); );
@ -447,18 +446,18 @@ class BalancedTestSuite extends TestSuite {
const prediction3a = manager.predict(0, 1, { x: 50, y: 50 }); const prediction3a = manager.predict(0, 1, { x: 50, y: 50 });
this._plotPrediction(graph3, prediction3a); this._plotPrediction(graph3, prediction3a);
$assert( $assert(
prediction3a.position.x == manager.find(2).getPosition().x && prediction3a.position.x === manager.find(2).getPosition().x &&
prediction3a.position.y > manager.find(2).getPosition().y, prediction3a.position.y > manager.find(2).getPosition().y,
'Prediction is incorrectly positioned', 'Prediction is incorrectly positioned',
); );
$assert(prediction3a.order == 4, 'Prediction order should be 4'); $assert(prediction3a.order === 4, 'Prediction order should be 4');
const prediction3b = manager.predict(0, 1, { x: 50, y: -50 }); const prediction3b = manager.predict(0, 1, { x: 50, y: -50 });
this._plotPrediction(graph3, prediction3b); this._plotPrediction(graph3, prediction3b);
$assert( $assert(
prediction3b.position.x == manager.find(1).getPosition().x && prediction3b.position.x === manager.find(1).getPosition().x &&
prediction3b.position.y == manager.find(1).getPosition().y && prediction3b.position.y === manager.find(1).getPosition().y &&
prediction3b.order == manager.find(1).getOrder(), prediction3b.order === manager.find(1).getOrder(),
'Prediction should be the exact same as dragged node', 'Prediction should be the exact same as dragged node',
); );
@ -466,29 +465,29 @@ class BalancedTestSuite extends TestSuite {
this._plotPrediction(graph3, prediction3c); this._plotPrediction(graph3, prediction3c);
$assert( $assert(
prediction3c.position.x < manager.find(0).getPosition().x && prediction3c.position.x < manager.find(0).getPosition().x &&
prediction3c.position.y == manager.find(0).getPosition().y, prediction3c.position.y === manager.find(0).getPosition().y,
'Prediction is incorrectly positioned', 'Prediction is incorrectly positioned',
); );
$assert(prediction3c.order == 1, 'Prediction order should be 1'); $assert(prediction3c.order === 1, 'Prediction order should be 1');
const prediction3d = manager.predict(0, 1, { x: -50, y: -50 }); const prediction3d = manager.predict(0, 1, { x: -50, y: -50 });
this._plotPrediction(graph3, prediction3d); this._plotPrediction(graph3, prediction3d);
$assert( $assert(
prediction3d.position.x < manager.find(0).getPosition().x && prediction3d.position.x < manager.find(0).getPosition().x &&
prediction3d.position.y == manager.find(0).getPosition().y, prediction3d.position.y === manager.find(0).getPosition().y,
'Prediction is incorrectly positioned', 'Prediction is incorrectly positioned',
); );
$assert(prediction3d.order == 1, 'Prediction order should be 1'); $assert(prediction3d.order === 1, 'Prediction order should be 1');
const prediction3e = manager.predict(0, 1, { x: 50, y: 0 }); const prediction3e = manager.predict(0, 1, { x: 50, y: 0 });
this._plotPrediction(graph3, prediction3e); this._plotPrediction(graph3, prediction3e);
$assert( $assert(
prediction3e.position.x == manager.find(1).getPosition().x && prediction3e.position.x === manager.find(1).getPosition().x &&
prediction3e.position.y == manager.find(1).getPosition().y, prediction3e.position.y === manager.find(1).getPosition().y,
'Prediction position should be the same as node 1', 'Prediction position should be the same as node 1',
); );
$assert( $assert(
prediction3e.order == manager.find(1).getOrder(), prediction3e.order === manager.find(1).getOrder(),
'Prediction order should be the same as node 1', 'Prediction order should be the same as node 1',
); );

View File

@ -10,7 +10,7 @@
"esModuleInterop": true, "esModuleInterop": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"declaration": true, "declaration": true,
"strictNullChecks": false, "strictNullChecks": true,
"rootDirs": [ "rootDirs": [
"src", "src",
] ]