Skip to content

Commit 6bfe9ba

Browse files
committed
[WIP!] Use jsdoc for embedded documentation on typedefs
1 parent ed4dcba commit 6bfe9ba

2 files changed

Lines changed: 102 additions & 54 deletions

File tree

index.d.ts

Lines changed: 53 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,61 +17,86 @@ export interface SnapshotOptions {
1717
id?: string;
1818
}
1919

20-
// When an assert fail, the message string will be shown in the error
2120
export interface Assertions {
22-
// Assert that actual is deep equal to expected
21+
/** Assert that `actual` is deep equal to `expected` */
2322
deepEqual<ValueType = any>(actual: ValueType, expected: ValueType, message?: string): void;
24-
// Failing assertion
23+
24+
/** Cause the test to fail */
2525
fail(message?: string): void;
26-
// Assert that actual is equal to false
26+
27+
/** Assert that `actual` is equal to false */
2728
false(actual: any, message?: string): void;
28-
// Assert that actual is falsy (false, 0, '', "", null, undefined, NaN)
29+
30+
/** Assert that `actual` is falsy (false, 0, '', null, undefined, NaN) */
2931
falsy(actual: any, message?: string): void;
30-
// Assert that error is falsy
32+
33+
/** Assert that `error` is falsy */
3134
ifError(error: any, message?: string): void;
32-
// Assert that actual is equal to expected (use deepEqual for objects/arrays)
35+
36+
/** Assert that `actual` is strictly equal to `expected` */
3337
is<ValueType = any>(actual: ValueType, expected: ValueType, message?: string): void;
34-
// Assert that actual is not equal to expected (use notDeepEqual for objects/arrays)
38+
39+
/** Assert that `actual` is not strictly equal to `expected` */
3540
not<ValueType = any>(actual: ValueType, expected: ValueType, message?: string): void;
36-
// Assert that actual is not deep equal to expected
41+
42+
/** Assert that `actual` is not deep equal to `expected` */
3743
notDeepEqual<ValueType = any>(actual: ValueType, expected: ValueType, message?: string): void;
38-
// Assert that string does not follow the regex pattern
44+
45+
/** Assert that `string` does not match the regex pattern */
3946
notRegex(string: string, regex: RegExp, message?: string): void;
40-
// Assert that a function that never returns does not throw an error
47+
48+
/** Assert that a function does not throw */
4149
notThrows(value: () => never, message?: string): void;
42-
// Assert that a function that returns an observable does not throw an error
50+
51+
/** Assert that a function that returns an observable does not throw */
4352
notThrows(value: () => ObservableLike, message?: string): Promise<void>;
44-
// Assert that a function that returns a promise does not throw an error
53+
54+
/** Assert that a function that returns a promise throws an error */
4555
notThrows(value: () => PromiseLike<any>, message?: string): Promise<void>;
46-
// Assert that a function that returns any value does not throw an error
56+
57+
/** Assert that a function does not throw */
4758
notThrows(value: () => any, message?: string): void;
48-
// Assert that an observable does not throw an error
59+
60+
/** Assert that an observable does not throw */
4961
notThrows(value: ObservableLike, message?: string): Promise<void>;
50-
// Assert that a promise does not throw an error
62+
63+
/** Assert that a promise does not throw */
5164
notThrows(value: PromiseLike<any>, message?: string): Promise<void>;
52-
// Passing assertion
65+
66+
/** Passing assertion */
5367
pass(message?: string): void;
54-
// Assert that string follows the regex pattern
68+
69+
/** Assert that string match the regex pattern */
5570
regex(string: string, regex: RegExp, message?: string): void;
56-
// Assert that expected matches a snapshot
71+
72+
/** Assert that expected matches a snapshot */
5773
snapshot(expected: any, message?: string): void;
58-
// Assert that expected matches a snapshot with option `id`
74+
75+
/** Assert that expected matches a snapshot with option `id` */
5976
snapshot(expected: any, options: SnapshotOptions, message?: string): void;
60-
// Assert that a function that never returns throws an error
77+
78+
/** Assert that a function that returns any value throws an error */
6179
throws(value: () => never, error?: ThrowsErrorValidator, message?: string): any;
62-
// Assert that a function that returns an observable throws an error
80+
81+
/** Assert that a function that returns an observable throws an error */
6382
throws(value: () => ObservableLike, error?: ThrowsErrorValidator, message?: string): Promise<any>;
64-
// Assert that a function that returns a promise throws an error
83+
84+
/** Assert that a function that returns a promise throws an error */
6585
throws(value: () => PromiseLike<any>, error?: ThrowsErrorValidator, message?: string): Promise<any>;
66-
// Assert that a function that returns any value throws an error
86+
87+
/** Assert that a function that returns any value throws an error */
6788
throws(value: () => any, error?: ThrowsErrorValidator, message?: string): any;
68-
// Assert that an observable throws an error
89+
90+
/** Assert that an observable throws an error */
6991
throws(value: ObservableLike, error?: ThrowsErrorValidator, message?: string): Promise<any>;
70-
// Assert that a promise throws an error
92+
93+
/** Assert that a promise throws an error */
7194
throws(value: PromiseLike<any>, error?: ThrowsErrorValidator, message?: string): Promise<any>;
72-
// Assert that actual is equal to true
95+
96+
/** Assert that actual is equal to true */
7397
true(actual: any, message?: string): void;
74-
// Assert that actual is truthy ('0', 'false', [], {}, function() {}, etc.)
98+
99+
/** Assert that actual is truthy ('0', 'false', [], {}, function() {}, etc.) */
75100
truthy(actual: any, message?: string): void;
76101
}
77102

index.js.flow

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,57 +22,80 @@ export interface SnapshotOptions {
2222
id?: string;
2323
}
2424

25-
// When an assert fail, the message string will be shown in the error
2625
export interface Assertions {
27-
// Assert that actual is deep equal to expected
26+
/** Assert that `actual` is deep equal to `expected` */
2827
deepEqual(actual: any, expected: any, message?: string): void;
29-
// Failing assertion
28+
29+
/** Cause the test to fail */
3030
fail(message?: string): void;
31-
// Assert that actual is equal to false
31+
32+
/** Assert that `actual` is equal to false */
3233
false(actual: any, message?: string): void;
33-
// Assert that actual is falsy (false, 0, '', "", null, undefined, NaN)
34+
35+
/** Assert that `actual` is falsy (false, 0, '', null, undefined, NaN) */
3436
falsy(actual: any, message?: string): void;
35-
// Assert that error is falsy
37+
38+
/** Assert that `error` is falsy */
3639
ifError(error: any, message?: string): void;
37-
// Assert that actual is equal to expected (use deepEqual for objects/arrays)
40+
41+
/** Assert that `actual` is strictly equal to `expected` */
3842
is(actual: any, expected: any, message?: string): void;
39-
// Assert that actual is not equal to expected (use notDeepEqual for objects/arrays)
43+
44+
/** Assert that `actual` is not strictly equal to `expected` */
4045
not(actual: any, expected: any, message?: string): void;
41-
// Assert that actual is not deep equal to expected
46+
47+
/** Assert that `actual` is not deep equal to `expected` */
4248
notDeepEqual(actual: any, expected: any, message?: string): void;
43-
// Assert that string does not follow the regex pattern
49+
50+
/** Assert that `string` does not match the regex pattern */
4451
notRegex(string: string, regex: RegExp, message?: string): void;
45-
// Assert that a function that returns an observable does not throw an error
52+
53+
/** Assert that a function that returns an observable does not throw */
4654
notThrows(value: () => ObservableLike, message?: string): Promise<void>;
47-
// Assert that a function that returns a promise does not throw an error
55+
56+
/** Assert that a function that returns a promise does not throw */
4857
notThrows(value: () => PromiseLike<any>, message?: string): Promise<void>;
49-
// Assert that a function that returns any value does not throw an error
58+
59+
/** Assert that a function does not throw */
5060
notThrows(value: () => any, message?: string): void;
51-
// Assert that an observable does not throw an error
61+
62+
/** Assert that an observable does not throw */
5263
notThrows(value: ObservableLike, message?: string): Promise<void>;
53-
// Assert that a promise does not throw an error
64+
65+
/** Assert that a promise does not throw */
5466
notThrows(value: PromiseLike<any>, message?: string): Promise<void>;
55-
// Passing assertion
67+
68+
/** Passing assertion */
5669
pass(message?: string): void;
57-
// Assert that string follows the regex pattern
70+
71+
/** Assert that string match the regex pattern */
5872
regex(string: string, regex: RegExp, message?: string): void;
59-
// Assert that expected matches a snapshot
73+
74+
/** Assert that expected matches a snapshot */
6075
snapshot(expected: any, message?: string): void;
61-
// Assert that expected matches a snapshot with option `id`
76+
77+
/** Assert that expected matches a snapshot with option `id` */
6278
snapshot(expected: any, options: SnapshotOptions, message?: string): void;
63-
// Assert that a function that returns an observable throws an error
79+
80+
/** Assert that a function that returns an observable throws an error */
6481
throws(value: () => ObservableLike, error?: ThrowsErrorValidator, message?: string): Promise<any>;
65-
// Assert that a function that returns a promise throws an error
82+
83+
/** Assert that a function that returns a promise throws an error */
6684
throws(value: () => PromiseLike<any>, error?: ThrowsErrorValidator, message?: string): Promise<any>;
67-
// Assert that a function that returns any value throws an error
85+
86+
/** Assert that a function throws an error */
6887
throws(value: () => any, error?: ThrowsErrorValidator, message?: string): any;
69-
// Assert that an observable throws an error
88+
89+
/** Assert that an observable throws an error */
7090
throws(value: ObservableLike, error?: ThrowsErrorValidator, message?: string): Promise<any>;
71-
// Assert that a promise throws an error
91+
92+
/** Assert that a promise throws an error */
7293
throws(value: PromiseLike<any>, error?: ThrowsErrorValidator, message?: string): Promise<any>;
73-
// Assert that actual is equal to true
94+
95+
/** Assert that actual is equal to true */
7496
true(actual: any, message?: string): void;
75-
// Assert that actual is truthy ('0', 'false', [], {}, function() {}, etc.)
97+
98+
/** Assert that actual is truthy ('0', 'false', [], {}, function() {}, etc.) */
7699
truthy(actual: any, message?: string): void;
77100
}
78101

0 commit comments

Comments
 (0)