Skip to content

Commit fcd7922

Browse files
author
Maximilian Wehrstedt
committed
test: fixed failing tests
1 parent edadd85 commit fcd7922

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

src/test/function/test.jsdoc-tsd-parser.ts

+12-16
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,17 @@ describe("JSDocTsdParser.parse.function", () => {
222222
expect(functionData.returns[0].type.names.length).to.equal(1);
223223

224224
// add different array parameters to the function
225+
// be sure that the types passed below are a valid return value of jsdoc, e.g. JSDoc transforms string[] to Array.<string>
225226
functionData.params = [
226227
{
227228
name: "param1",
228229
type: {
229230
names: [
230231
"Array.<string>",
231232
"array.<boolean>",
232-
"object[]",
233+
"Array.<object>",
233234
"array",
234235
"Array",
235-
"[]",
236-
"*[]",
237236
"Array.<*>",
238237
"array.<*>"
239238
]
@@ -252,20 +251,20 @@ describe("JSDocTsdParser.parse.function", () => {
252251

253252
// ensure that every type is mapped correctly
254253
let union = functionDeclarations[0].parameters[0].type as dom.UnionType;
255-
expect(union.members.length).to.eq(9);
254+
expect(union.members.length).to.eq(7);
256255

257256
expect((union.members[0] as any).kind).to.eq("array");
258257
expect((union.members[0] as any).type).to.eq(dom.type.string);
259258
expect((union.members[1] as any).kind).to.eq("array");
260259
expect((union.members[1] as any).type).to.eq(dom.type.boolean);
261260
expect((union.members[2] as any).kind).to.eq("array");
262261
expect((union.members[2] as any).type).to.eq(dom.type.object);
263-
expect(union.members[3]).to.eq(dom.type.any);
264-
expect(union.members[4]).to.eq(dom.type.any);
265-
expect(union.members[5]).to.eq(dom.type.any);
266-
expect(union.members[6]).to.eq(dom.type.any);
267-
expect(union.members[7]).to.eq(dom.type.any);
268-
expect(union.members[8]).to.eq(dom.type.any);
262+
263+
const anyArray = dom.type.array(dom.type.any);
264+
expect(union.members[3]).to.deep.eq(anyArray);
265+
expect(union.members[4]).to.deep.eq(anyArray);
266+
expect(union.members[5]).to.deep.eq(anyArray);
267+
expect(union.members[6]).to.deep.eq(anyArray);
269268

270269
});
271270

@@ -287,8 +286,8 @@ describe("JSDocTsdParser.parse.function", () => {
287286
names: [
288287
"bool",
289288
"boolean",
290-
"bool[]",
291-
"boolean[]"
289+
"Array.<bool>",
290+
"Array.<boolean>"
292291
]
293292
},
294293
comment: "..",
@@ -360,7 +359,6 @@ describe("JSDocTsdParser.parse.function", () => {
360359
description: "..",
361360
type: {
362361
names: [
363-
primitiveTypeValue + "[]",
364362
"Array.<" + primitiveTypeValue + ">"
365363
]
366364
}
@@ -374,11 +372,9 @@ describe("JSDocTsdParser.parse.function", () => {
374372
expect(functionDeclarations.length).to.eq(1);
375373

376374
let union = functionDeclarations[0].returnType as dom.UnionType;
377-
expect(union.members.length).to.eq(2);
375+
expect(union.members.length).to.eq(1);
378376
expect((union.members[0] as any).kind).to.eq("array");
379377
expect((union.members[0] as any).type).to.eq(primitiveTypeValue);
380-
expect((union.members[1] as any).kind).to.eq("array");
381-
expect((union.members[1] as any).type).to.eq(primitiveTypeValue);
382378
}
383379
});
384380

0 commit comments

Comments
 (0)