Skip to content

Commit d5d4fbc

Browse files
committed
Update unit tests
1 parent 5244864 commit d5d4fbc

4 files changed

Lines changed: 19 additions & 23 deletions

File tree

‎libraries/api-extractor/src/ApiDefinitionReference.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ export default class ApiDefinitionReference {
103103
public static createFromString(apiReferenceExpr: string,
104104
reportError: (message: string) => void): ApiDefinitionReference {
105105
if (!apiReferenceExpr || apiReferenceExpr.split(' ').length > 1) {
106-
reportError('API reference expression must be of the form: ' +
107-
'\'scopeName/packageName:exportName.memberName | display text\'' +
108-
'where the \'|\' is required if a display text is provided');
106+
reportError('An API item reference must use the notation: "@scopeName/packageName:exportName.memberName"');
109107
return;
110108
}
111109

‎libraries/api-extractor/src/definitions/test/ApiDocumentation.test.ts‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,21 @@ describe('ApiDocumentation tests', function (): void {
6565
* - testInputs/example2/folder/MyDocumentedClass (10 errors)
6666
*/
6767

68-
assert.equal(capturedErrors.length, 10);
68+
console.log(JSON.stringify(capturedErrors));
69+
70+
assert.equal(capturedErrors.length, 8);
6971
assert.equal(capturedErrors[0].message, 'Cannot provide summary in JsDoc if @inheritdoc tag is given');
70-
assert.equal(capturedErrors[1].message, 'The JSDoc tag "@summary" is not supported in this context');
71-
assert.equal(
72-
capturedErrors[2].message, 'Unexpected text in JSDoc comment: "Mock class for testing JsDoc parser"'
73-
);
74-
assert.equal(capturedErrors[3].message, 'Unknown JSDoc tag "@badJsDocTag"');
75-
assert.equal(capturedErrors[4].message, 'Unknown tag name for inline tag.');
76-
assert.equal(capturedErrors[5].message, 'Too few parameters for @link inline tag.');
77-
assert.equal(capturedErrors[6].message, 'Unexpected text in JSDoc comment: "can not contain a tag"');
78-
assert.equal(capturedErrors[7].message, 'More than one API Tag was specified');
72+
assert.equal(capturedErrors[1].message, 'Unknown JSDoc tag "@badJsDocTag"');
73+
assert.equal(capturedErrors[2].message, 'Unknown tag name for inline tag.');
74+
assert.equal(capturedErrors[3].message, 'Too few parameters for @link inline tag.');
75+
assert.equal(capturedErrors[4].message, 'Unexpected text in JSDoc comment: "can not contain a tag"');
76+
assert.equal(capturedErrors[5].message, 'More than one API Tag was specified');
7977
assert.equal(
80-
capturedErrors[8].message,
81-
'API reference expression must be of the form: \'scopeName/packageName:exportName.memberName ' +
82-
'| display text\'where the \'|\' is required if a display text is provided'
78+
capturedErrors[6].message,
79+
'An API item reference must use the notation: "@scopeName/packageName:exportName.memberName"'
8380
);
8481
assert.equal(
85-
capturedErrors[9].message,
82+
capturedErrors[7].message,
8683
'inheritdoc source item is deprecated. Must provide @deprecated message or remove @inheritdoc inline tag.');
8784
});
8885

‎libraries/api-extractor/testInputs/example2/example2-output.json‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,12 @@
142142
"value": ". This block is entirely valid and a correct documentation object should be built for this ApiItem."
143143
}
144144
],
145-
"remarks": [],
145+
"remarks": [
146+
{
147+
"kind": "textDocElement",
148+
"value": "Mock class for testing JsDoc parser"
149+
}
150+
],
146151
"isBeta": false,
147152
"members": {
148153
"__constructor": {

‎libraries/api-extractor/testInputs/example2/src/MyDocumentedClass.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,9 @@ export function functionWithIncompleteParameterType(param1, param2: string): boo
7878
* correctly. It can contain a {@link https://bing.com/ | bing home}. This block is entirely
7979
* valid and a correct documentation object should be built for this ApiItem.
8080
*
81-
* @summary Mock class for testing JsDoc parser
8281
* @public
82+
* @remarks Mock class for testing JsDoc parser
8383
*/
84-
// (Error #2)
85-
// Error: The JSDoc tag "@summary" is not supported in this context
86-
// (Error #4)
87-
// Error: Unexpected text in JSDoc comment: "Mock class for testing JsDoc parser"
8884
export default class MyDocumentedClass {
8985

9086

0 commit comments

Comments
 (0)