Skip to content

Commit 5a4cb5e

Browse files
committed
re-correct the test
1 parent 35658e4 commit 5a4cb5e

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

tests/lib/entry.spec.mjs

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,33 @@ describe('docdown', () => {
2929
})
3030

3131
describe('::getAliases()', () => {
32-
/** @type {Object<string, [string[], string[]][]} */
32+
/** @type {Object<string, [string[], string[], string[]][]} */
3333
const dataset = {
3434
'no aliases': [
35-
[[], []],
35+
[[], [], []],
3636
],
3737
'one alias': [
38-
[['bat'], ['bat']],
38+
[['bat'], ['bat'], ['bat']],
3939
],
4040
'two aliases': [
41-
[['bar', 'bat'], ['bar']],
42-
[['bat', 'bar'], ['bat']],
41+
[['bar', 'bat'], ['bar'], ['bar', 'bat']],
42+
[['bat', 'bar'], ['bat'], ['bar', 'bat']],
4343
],
4444
'three aliases': [
45-
[['bar', 'bat', 'baz'], ['bar']],
46-
[['bat', 'bar', 'baz'], ['bat']],
45+
[['bar', 'bat', 'baz'], ['bar'], ['bar', 'bat', 'baz']],
46+
[['bat', 'bar', 'baz'], ['bat'], ['bar', 'bat', 'baz']],
4747
],
4848
};
4949

5050
for (const [test, datasets] of Object.entries(dataset)) {
5151
for (let i = 0; i < datasets.length; ++i) {
52-
const [aliases, expectation] = datasets[i];
52+
const [
53+
aliases,
54+
expectationMultipleTags,
55+
expectationMultipleValues,
56+
] = datasets[i];
5357

54-
void it(`${test} [${i}]`, () => {
58+
void it(`${test} [${i}] as multiple tags`, () => {
5559
const entry = new Entry(
5660
strip_test_spacing(
5761
`/**
@@ -68,8 +72,29 @@ describe('docdown', () => {
6872
'',
6973
);
7074

71-
assert.deepEqual(entry.getAliases().map((e) => e.getName()), expectation);
72-
assert.equal(entry.getAliases(0)?.getName(), expectation[0] || undefined);
75+
assert.deepEqual(entry.getAliases().map((e) => e.getName()), expectationMultipleTags);
76+
assert.equal(entry.getAliases(0)?.getName(), expectationMultipleTags[0] || undefined);
77+
})
78+
79+
void it(`${test} [${i}] as multiple values`, () => {
80+
const entry = new Entry(
81+
strip_test_spacing(
82+
`/**
83+
* Some function
84+
*
85+
* ${
86+
aliases.length > 0
87+
? `@alias ${aliases.join(', ')}`
88+
: ''
89+
}
90+
*/
91+
function foo(foo) {}`
92+
),
93+
'',
94+
);
95+
96+
assert.deepEqual(entry.getAliases().map((e) => e.getName()), expectationMultipleValues);
97+
assert.equal(entry.getAliases(0)?.getName(), expectationMultipleValues[0] || undefined);
7398
})
7499
}
75100
}

0 commit comments

Comments
 (0)