Skip to content

Commit 361a440

Browse files
committed
All unit tests are now passing
1 parent 63aef44 commit 361a440

9 files changed

Lines changed: 72 additions & 21 deletions

File tree

‎libraries/api-extractor/src/generators/test/ApiFileGenerator.test.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ function testErrorHandler(message: string, fileName: string, lineNumber: number)
2929
capturedErrors.push({ message, fileName, lineNumber });
3030
}
3131

32+
function assertCapturedErrors(expectedMessages: string[]): void {
33+
assert.deepEqual(capturedErrors.map(x => x.message), expectedMessages,
34+
'The captured errors did not match the expected output.');
35+
}
36+
3237
describe('ApiFileGenerator tests', function (): void {
3338
this.timeout(10000);
3439

@@ -62,10 +67,10 @@ describe('ApiFileGenerator tests', function (): void {
6267
/**
6368
* Errors can be found in testInputs/folder/MyClass
6469
*/
65-
assert.equal(capturedErrors.length, 2);
66-
assert.equal(capturedErrors[0].message, 'The JSDoc tag "@badAedocTag" is not supported by AEDoc');
67-
assert.equal(capturedErrors[1].message, 'Unexpected text in AEDoc comment: '
68-
+ '"(Error #1 is the bad tag) Text can no..."');
70+
assertCapturedErrors([
71+
'The JSDoc tag "@badAedocTag" is not supported by AEDoc',
72+
'Unexpected text in AEDoc comment: "(Error #1 is the bad tag) Text can no..."'
73+
]);
6974
});
7075

7176
it('Example 2', function (): void {

‎libraries/api-extractor/src/test/DocItemLoader.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('DocItemLoader tests', function (): void {
3232
this.timeout(10000);
3333

3434
describe('Basic Tests', function (): void {
35-
it('Example 3', function (): void {
35+
it('Example 3', function (): void {
3636
const inputFolder: string = './testInputs/example3';
3737
const outputJsonFile: string = './lib/example3-output.json';
3838
const outputApiFile: string = './lib/example3-output.api.ts';

‎libraries/api-extractor/testInputs/example1/example1-output.api.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// WARNING: The underscore prefix ("_") should only be used with definitions that are explicitly marked as @internal
2+
// @public
13
class ___proto__ {
24
// (undocumented)
35
public propertyIsEnumerable: string;
@@ -16,7 +18,7 @@ class _PreapprovedInternalClass {
1618
}
1719

1820

19-
// (undocumented)
21+
// @public (undocumented)
2022
class A extends __proto__, implements hasOwnProperty {
2123
// (undocumented)
2224
___lookupSetter__: __proto__;
@@ -56,13 +58,13 @@ class BetaTaggedClass {
5658
public plainMethod(): void;
5759
}
5860

59-
// (undocumented)
61+
// @public (undocumented)
6062
interface hasOwnProperty {
6163
// (undocumented)
6264
___lookupSetter__: __proto__;
6365
}
6466

65-
// (undocumented)
67+
// @public (undocumented)
6668
class MyClass {
6769
// (undocumented)
6870
public field: number;
@@ -72,7 +74,7 @@ class MyClass {
7274
public test(): void;
7375
}
7476

75-
// (undocumented)
77+
// @public (undocumented)
7678
export function publicFunction(param: number): string;
7779

7880
// @public

‎libraries/api-extractor/testInputs/example1/folder/MyClass.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* @badAedocTag (Error #1 is the bad tag) Text can not come after a tag unless it is a parameter of
44
* the tag. It must come in the first few sentences of the AEDoc or come after
55
* an \@internalremarks tag. (Error #2 text coming after a tag that is not \@internalremarks)
6+
* @public
67
*/
78
export default class MyClass {
89
public test(): void {
@@ -81,18 +82,21 @@ const privateField = 123;
8182
/**
8283
* This is testing identifiers whose name is the same as the
8384
* members of the object prototype.
85+
* @public
8486
*/
8587
export class __proto__ {
8688
public propertyIsEnumerable: string;
8789
}
8890

91+
/** @public */
8992
export interface hasOwnProperty {
9093
__lookupSetter__: __proto__;
9194
}
9295

96+
/** @public */
9397
export class A extends __proto__ implements hasOwnProperty {
94-
__lookupSetter__: __proto__;
95-
public __proto__(__proto__: string): __proto__ {
96-
return undefined;
97-
}
98-
}
98+
__lookupSetter__: __proto__;
99+
public __proto__(__proto__: string): __proto__ {
100+
return undefined;
101+
}
102+
}

‎libraries/api-extractor/testInputs/example1/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function privateFunction(): number {
1414
return 123;
1515
}
1616

17+
/** @public */
1718
export function publicFunction(param: number): string {
1819
return 'hi' + param;
1920
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
// WARNING: Unable to find a documentation file ("es6-collections.api.json") for the referenced package
2+
// @public
23
interface IExternalPackageLookupInheritDoc {
34
}
45

56
// WARNING: __constructor has incomplete type information
7+
// @public
68
class IncompleteTypeConstructor {
79
}
810

11+
// @public
912
enum inheritDisplayMode {
1013
}
1114

15+
// @public
1216
enum inheritDisplayModeError {
1317
}
1418

19+
// @public
1520
enum inheritDisplayModeErrorDeprecated {
1621
}
1722

18-
// @deprecated
23+
// @public @deprecated
1924
enum inheritDisplayModeNoErrorDeprecated {
2025
}
2126

@@ -47,9 +52,11 @@ class MyDocumentedClass {
4752
}
4853

4954
// WARNING: Unable to find referenced export "@microsoft/sp-core-library:Display""
55+
// @public
5056
enum packageLocatedButExportNotFound {
5157
}
5258

59+
// @public
5360
enum TestMissingCommentStar {
5461
}
5562

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,28 @@
22
* Degenerate comment
33
star missing here
44
* end of comment
5+
* @public
56
*/
67
export enum TestMissingCommentStar {
78
}
89

910
/**
1011
* {@inheritdoc es6-collections:ForEachable}
12+
* @public
1113
*/
1214
export interface IExternalPackageLookupInheritDoc {
1315
}
1416

1517
/**
1618
* {@inheritdoc @microsoft/sp-core-library:DisplayMode}
19+
* @public
1720
*/
1821
export enum inheritDisplayMode {
1922
}
2023

2124
/**
2225
* {@inheritdoc @microsoft/sp-core-library:Display}
26+
* @public
2327
*/
2428
export enum packageLocatedButExportNotFound {
2529
}
@@ -31,6 +35,7 @@ export enum packageLocatedButExportNotFound {
3135
* It will not appear in the output json files because of the error.
3236
*
3337
* {@inheritdoc @microsoft/sp-core-library:DisplayMode}
38+
* @public
3439
*/
3540
// (Error #1)
3641
// Error: Cannot provide summary in AEDoc if @inheritdoc tag is given
@@ -41,6 +46,8 @@ export enum inheritDisplayModeError {
4146
/**
4247
* {@inheritdoc @microsoft/sp-core-library:DisplayModeDeprecated}
4348
*
49+
* @public
50+
*
4451
*/
4552
export enum inheritDisplayModeErrorDeprecated {
4653

@@ -50,6 +57,7 @@ export enum inheritDisplayModeErrorDeprecated {
5057
* {@inheritdoc @microsoft/sp-core-library:DisplayModeDeprecated}
5158
* @deprecated - deprecated message must be present if the inherited Api item
5259
* is deprecated. If not error is reported.
60+
* @public
5361
*/
5462
export enum inheritDisplayModeNoErrorDeprecated {
5563
}
@@ -58,6 +66,7 @@ export enum inheritDisplayModeNoErrorDeprecated {
5866
* This function has incomplete type information on the return value and should not
5967
* be printed to the API file, instead a warning comment should be present
6068
* at the bottom of the API file.
69+
* @public
6170
*/
6271
export function functionWithIncompleteReturnType(param1: string, param2: string) {
6372
return false;
@@ -67,6 +76,7 @@ export function functionWithIncompleteReturnType(param1: string, param2: string)
6776
* This function has incomplete type information on a parameter and should not
6877
* be printed to the API file, instead a warning comment should be present at the
6978
* bottom of the API file.
79+
* @public
7080
*/
7181
export function functionWithIncompleteParameterType(param1, param2: string): boolean {
7282
return false;
@@ -78,8 +88,8 @@ export function functionWithIncompleteParameterType(param1, param2: string): boo
7888
* correctly. It can contain a {@link https://bing.com/ | bing home}. This block is entirely
7989
* valid and a correct documentation object should be built for this ApiItem.
8090
*
81-
* @public
8291
* @remarks Mock class for testing JsDoc parser
92+
* @public
8393
*/
8494
export default class MyDocumentedClass {
8595

@@ -213,6 +223,7 @@ export default class MyDocumentedClass {
213223
* comment should be printed about this class declaration. The constructor
214224
* will not appear in the json file because the type information is
215225
* incomplete.
226+
* @public
216227
*/
217228
export class IncompleteTypeConstructor {
218229
constructor(name, age: number) {

‎libraries/api-extractor/testInputs/example3/example3-output.api.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,64 @@
22
enum _internalEnum {
33
}
44

5+
// @public
56
enum inheritEnumValues {
67
index_one = 1,
78
index_zero = 0
89
}
910

10-
// (undocumented)
11+
// @public (undocumented)
1112
enum inheritLocalCircularDependencyOne {
1213
}
1314

14-
// (undocumented)
15+
// @public (undocumented)
1516
enum inheritLocalCircularDependencyTwo {
1617
}
1718

19+
// @public
1820
enum inheritLocalOptionOne {
1921
}
2022

2123
// WARNING: Unable to find referenced member "MyClass.methodWithTwoParams"
24+
// @public
2225
export function inheritLocalOptionTwoFunction(): void;
2326

27+
// @public
2428
interface IStructuredTypeInherit {
2529
thisIsTypeLiteral: [{name: string, age: number}];
2630
}
2731

32+
// @public
2833
interface IStructuredTypeSource {
2934
thisIsTypeLiteral: {
3035
[ key: string ]: string;
3136
renderingArea: string;
3237
}
3338
}
3439

40+
// @public
3541
class jsonResolutionClass {
3642
public jsonResolutionMethod(): boolean;
3743
}
3844

45+
// @public
3946
export function jsonResolutionFunction(): boolean;
4047

48+
// @public
4149
class MyClass {
4250
}
4351

4452
// @public
4553
enum publicEnum {
4654
}
4755

56+
// @public
4857
enum sourceEnumValuesDoc {
4958
one = 1,
5059
zero = 0
5160
}
5261

62+
// @public
5363
enum testingLinks {
5464
}
5565

0 commit comments

Comments
 (0)