diff --git a/src/placing.js b/src/placing.js index c2b761d..356e338 100644 --- a/src/placing.js +++ b/src/placing.js @@ -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 => { diff --git a/src/rendering.js b/src/rendering.js index 80b2179..a1d3aca 100644 --- a/src/rendering.js +++ b/src/rendering.js @@ -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); diff --git a/test/placing.test.js b/test/placing.test.js index c6627e2..4c39c01 100644 --- a/test/placing.test.js +++ b/test/placing.test.js @@ -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', () => { diff --git a/test/rendering.test.js b/test/rendering.test.js index 8e618a1..20e2237 100644 --- a/test/rendering.test.js +++ b/test/rendering.test.js @@ -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\''); } }); }); \ No newline at end of file