Skip to content

Commit 1faf668

Browse files
authored
tests: Add @example to test fixtures (#21)
1 parent aad02f1 commit 1faf668

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

src/test/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ In `capacitor.config.json`:
228228
{
229229
"plugins": {
230230
"Haptics": {
231-
"style": undefined,
232-
"duration": undefined
231+
"style": "native",
232+
"duration": 123
233233
}
234234
}
235235
}
@@ -245,8 +245,8 @@ import { CapacitorConfig } from '@capacitor/cli';
245245
const config: CapacitorConfig = {
246246
plugins: {
247247
Haptics: {
248-
style: undefined,
249-
duration: undefined,
248+
style: "native",
249+
duration: 123,
250250
},
251251
},
252252
};

src/test/docs.json

+8
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,10 @@
425425
{
426426
"text": "native",
427427
"name": "default"
428+
},
429+
{
430+
"text": "\"native\"",
431+
"name": "example"
428432
}
429433
],
430434
"docs": "Configure the style.",
@@ -437,6 +441,10 @@
437441
{
438442
"text": "1.2.3",
439443
"name": "since"
444+
},
445+
{
446+
"text": "123",
447+
"name": "example"
440448
}
441449
],
442450
"docs": "Configure the duration.",

src/test/fixtures/definitions.ts

+2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ declare module '@capacitor/cli' {
1111
*
1212
* @since 1.0.0
1313
* @default native
14+
* @example "native"
1415
*/
1516
style?: 'none' | 'native';
1617

1718
/**
1819
* Configure the duration.
1920
*
2021
* @since 1.2.3
22+
* @example 123
2123
*/
2224
duration?: number;
2325
};

src/test/parse.spec.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,23 @@ describe('parse', () => {
155155
expect(p0.docs).toBe(`Configure the style.`);
156156
expect(p0.type).toBe(`'none' | 'native' | undefined`);
157157
expect(p0.complexTypes).toHaveLength(0);
158-
expect(p0.tags).toHaveLength(2);
158+
expect(p0.tags).toHaveLength(3);
159159
expect(p0.tags[0].name).toBe(`since`);
160160
expect(p0.tags[0].text).toBe(`1.0.0`);
161161
expect(p0.tags[1].name).toBe(`default`);
162162
expect(p0.tags[1].text).toBe(`native`);
163+
expect(p0.tags[2].name).toBe(`example`);
164+
expect(p0.tags[2].text).toBe(`"native"`);
163165

164166
const p1 = p.properties[1];
165167
expect(p1.name).toBe(`duration`);
166168
expect(p1.docs).toBe(`Configure the duration.`);
167169
expect(p1.type).toBe(`number | undefined`);
168170
expect(p1.complexTypes).toHaveLength(0);
169-
expect(p1.tags).toHaveLength(1);
171+
expect(p1.tags).toHaveLength(2);
170172
expect(p1.tags[0].name).toBe(`since`);
171173
expect(p1.tags[0].text).toBe(`1.2.3`);
174+
expect(p1.tags[1].name).toBe(`example`);
175+
expect(p1.tags[1].text).toBe(`123`);
172176
});
173177
});

0 commit comments

Comments
 (0)