Skip to content

Commit

Permalink
tests: Add @example to test fixtures (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed Mar 3, 2021
1 parent aad02f1 commit 1faf668
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ In `capacitor.config.json`:
{
"plugins": {
"Haptics": {
"style": undefined,
"duration": undefined
"style": "native",
"duration": 123
}
}
}
Expand All @@ -245,8 +245,8 @@ import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
plugins: {
Haptics: {
style: undefined,
duration: undefined,
style: "native",
duration: 123,
},
},
};
Expand Down
8 changes: 8 additions & 0 deletions src/test/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@
{
"text": "native",
"name": "default"
},
{
"text": "\"native\"",
"name": "example"
}
],
"docs": "Configure the style.",
Expand All @@ -437,6 +441,10 @@
{
"text": "1.2.3",
"name": "since"
},
{
"text": "123",
"name": "example"
}
],
"docs": "Configure the duration.",
Expand Down
2 changes: 2 additions & 0 deletions src/test/fixtures/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ declare module '@capacitor/cli' {
*
* @since 1.0.0
* @default native
* @example "native"
*/
style?: 'none' | 'native';

/**
* Configure the duration.
*
* @since 1.2.3
* @example 123
*/
duration?: number;
};
Expand Down
8 changes: 6 additions & 2 deletions src/test/parse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,23 @@ describe('parse', () => {
expect(p0.docs).toBe(`Configure the style.`);
expect(p0.type).toBe(`'none' | 'native' | undefined`);
expect(p0.complexTypes).toHaveLength(0);
expect(p0.tags).toHaveLength(2);
expect(p0.tags).toHaveLength(3);
expect(p0.tags[0].name).toBe(`since`);
expect(p0.tags[0].text).toBe(`1.0.0`);
expect(p0.tags[1].name).toBe(`default`);
expect(p0.tags[1].text).toBe(`native`);
expect(p0.tags[2].name).toBe(`example`);
expect(p0.tags[2].text).toBe(`"native"`);

const p1 = p.properties[1];
expect(p1.name).toBe(`duration`);
expect(p1.docs).toBe(`Configure the duration.`);
expect(p1.type).toBe(`number | undefined`);
expect(p1.complexTypes).toHaveLength(0);
expect(p1.tags).toHaveLength(1);
expect(p1.tags).toHaveLength(2);
expect(p1.tags[0].name).toBe(`since`);
expect(p1.tags[0].text).toBe(`1.2.3`);
expect(p1.tags[1].name).toBe(`example`);
expect(p1.tags[1].text).toBe(`123`);
});
});

0 comments on commit 1faf668

Please sign in to comment.