more unit tests
This commit is contained in:
+2
-2
@@ -323,13 +323,13 @@ module.exports = (options) => {
|
||||
Object.keys(nodes).forEach(key => {
|
||||
const res = utils.isValid(nodes[key], NODE_DEF);
|
||||
if (res)
|
||||
throw `Node '${key}' is invalid at key ${res}`;
|
||||
throw `Node '${key}' is invalid at key '${res}'`;
|
||||
});
|
||||
|
||||
links.forEach((link, i) => {
|
||||
const res = utils.isValid(link, LINK_DEF);
|
||||
if (res)
|
||||
throw `Link ${i} (${link.from}->${link.to}) is invalid at key ${res}`;
|
||||
throw `Link ${i} (${link.from}->${link.to}) is invalid at key '${res}'`;
|
||||
});
|
||||
|
||||
Object.values(nodes).forEach(node => {
|
||||
|
||||
+2
-2
@@ -325,13 +325,13 @@ module.exports = (options) => {
|
||||
Object.keys(nodes).forEach(key => {
|
||||
const res = utils.isValid(nodes[key], NODE_DEF);
|
||||
if (res)
|
||||
throw `Node '${key}' is invalid at key ${res}`;
|
||||
throw `Node '${key}' is invalid at key '${res}'`;
|
||||
});
|
||||
|
||||
links.forEach((link, i) => {
|
||||
const res = utils.isValid(link, LINK_DEF);
|
||||
if (res)
|
||||
throw `Link ${i} (${link.from}->${link.to}) is invalid at key ${res}`;
|
||||
throw `Link ${i} (${link.from}->${link.to}) is invalid at key '${res}'`;
|
||||
});
|
||||
|
||||
const bounds = self.getBounds(nodes);
|
||||
|
||||
@@ -403,19 +403,19 @@ describe('compute', () => {
|
||||
test('invalid node', () => {
|
||||
try {
|
||||
placing().compute({
|
||||
'a': {name: 'a', x: 'hello'}
|
||||
'a': {name: 'a'}, 'b': {name: 'b', x: 'hello'}
|
||||
}, []);
|
||||
fail('no error thrown');
|
||||
} catch (err) {
|
||||
expect(err).toBe('Node \'a\' is invalid at key x');
|
||||
expect(err).toBe('Node \'b\' is invalid at key \'x\'');
|
||||
}
|
||||
});
|
||||
test('invalid link', () => {
|
||||
try {
|
||||
placing().compute({}, [{from: 'a', to: 5}]);
|
||||
placing().compute({}, [{from: 'a', to: 'b'}, {from: 'a', to: 5}]);
|
||||
fail('no error thrown');
|
||||
} catch (err) {
|
||||
expect(err).toBe('Link 0 (a->5) is invalid at key to');
|
||||
expect(err).toBe('Link 1 (a->5) is invalid at key \'to\'');
|
||||
}
|
||||
});
|
||||
test('3 nodes no link', () => {
|
||||
|
||||
@@ -177,19 +177,19 @@ describe('compute', () => {
|
||||
test('invalid node', () => {
|
||||
try {
|
||||
rendering().compute({
|
||||
'a': {name: 'a', icon: 5}
|
||||
'a': {name: 'a', icon: '', x: 0, y: 0}, 'b': {name: 'b', icon: 5}
|
||||
}, []);
|
||||
fail('no error thrown');
|
||||
} catch (err) {
|
||||
expect(err).toBe('Node \'a\' is invalid at key icon');
|
||||
expect(err).toBe('Node \'b\' is invalid at key \'icon\'');
|
||||
}
|
||||
});
|
||||
test('invalid link', () => {
|
||||
try {
|
||||
rendering().compute({}, [{from: 'a', to: 'b', type: 5}]);
|
||||
rendering().compute({}, [{from: 'a', to: 'b'}, {from: 'a', to: 'b', type: 5}]);
|
||||
fail('no error thrown');
|
||||
} catch (err) {
|
||||
expect(err).toBe('Link 0 (a->b) is invalid at key type');
|
||||
expect(err).toBe('Link 1 (a->b) is invalid at key \'type\'');
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user