Skip to content

Commit

Permalink
test: update test logic and cases in getUriList
Browse files Browse the repository at this point in the history
  • Loading branch information
lumirlumir committed Aug 17, 2024
1 parent 6616d4c commit 3aba258
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
20 changes: 20 additions & 0 deletions tests/utils/getUriList.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
},
];
9 changes: 7 additions & 2 deletions tests/utils/getUriList.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
});

0 comments on commit 3aba258

Please sign in to comment.