type enforcement unit tests

This commit is contained in:
Klemek
2019-07-15 10:59:43 +02:00
parent e699002c96
commit 83124b3da4
2 changed files with 37 additions and 1 deletions
+19 -1
View File
@@ -397,9 +397,27 @@ describe('compute', () => {
};
test('no nodes', () => {
const nodes = placing({diagonals: false}).compute({}, []);
const nodes = placing().compute({}, []);
expect(nodes).toEqual({});
});
test('invalid node', () => {
try {
placing().compute({
'a': {name: 'a', x: 'hello'}
}, []);
fail('no error thrown');
} catch (err) {
expect(err).toBe('node \'a\' is invalid at key x');
}
});
test('invalid link', () => {
try {
placing().compute({}, [{from: 'a', to: 5}]);
fail('no error thrown');
} catch (err) {
expect(err).toBe('link 0 (a->5) is invalid at key to');
}
});
test('3 nodes no link', () => {
const nodes = placing({diagonals: false}).compute(createNodes(3), []);
expect(nodes).toEqual({