diff --git a/tests/utils/getUriList.data.js b/tests/utils/getUriList.data.js index 25929bf..709ddaf 100644 --- a/tests/utils/getUriList.data.js +++ b/tests/utils/getUriList.data.js @@ -535,4 +535,24 @@ module.exports = [ }, expected: [], }, + /* throws error */ + { + actual: { + type: 'Document', + raw: '', + range: [0, 0], + loc: { + start: { + line: 1, + column: 0, + }, + end: { + line: 1, + column: 0, + }, + }, + children: [], + }, + expected: [], + }, ]; diff --git a/tests/utils/getUriList.spec.js b/tests/utils/getUriList.spec.js index facb512..2d1eee5 100644 --- a/tests/utils/getUriList.spec.js +++ b/tests/utils/getUriList.spec.js @@ -5,10 +5,15 @@ const getUriList = require('../../src/utils/getUriList'); /** * Tests for the `getUriList.js` */ -describe('Util getUriList deepStrictEqual testing', () => { +describe('Util getUriList deepStrictEqual and rejects testing', () => { testCases.forEach(({ actual, expected }) => { it(`${actual.raw} => ${expected.map(({ uri, type }) => `${uri} ${type}`).join(' / ')}`, async () => { - assert.deepStrictEqual((await getUriList(actual)).uriList, expected); + if (['Link', 'Image', 'Definition', 'Html'].includes(actual.type)) + assert.deepStrictEqual((await getUriList(actual)).uriList, expected); + else + await assert.rejects(async () => { + await getUriList(actual); + }); }); }); });