diff options
| author | ST-DDT <[email protected]> | 2023-10-14 10:50:05 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-14 10:50:05 +0200 |
| commit | e228183efc0fe74ee0438fbcb693932358921a20 (patch) | |
| tree | 9e22e728b9a407254935f2c47445756db25df696 /test/scripts | |
| parent | 5801c79a2df91395a62955c6481dca64a07065ee (diff) | |
| download | faker-e228183efc0fe74ee0438fbcb693932358921a20.tar.xz faker-e228183efc0fe74ee0438fbcb693932358921a20.zip | |
docs: fix bad Promise usage (#2475)
Diffstat (limited to 'test/scripts')
| -rw-r--r-- | test/scripts/apidoc/__snapshots__/signature.spec.ts.snap | 54 | ||||
| -rw-r--r-- | test/scripts/apidoc/signature.debug.ts | 4 | ||||
| -rw-r--r-- | test/scripts/apidoc/signature.example.ts | 13 |
3 files changed, 53 insertions, 18 deletions
diff --git a/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap b/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap index 79ceecf5..12e7df29 100644 --- a/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap +++ b/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap @@ -43,7 +43,7 @@ exports[`signature > analyzeSignature() > complexArrayParameter 1`] = ` "returns": "T", "seeAlsos": [], "since": "", - "sourcePath": "test/scripts/apidoc/signature.example.ts#L358", + "sourcePath": "test/scripts/apidoc/signature.example.ts#L367", "throws": undefined, } `; @@ -93,6 +93,7 @@ exports[`signature > analyzeSignature() > expected and actual methods are equal "optionsInterfaceParamMethodWithDefaults", "optionsParamMethod", "optionsTypeParamMethodWithDefaults", + "recordParamMethod", "requiredNumberParamMethod", "stringUnionParamMethod", ] @@ -198,7 +199,7 @@ exports[`signature > analyzeSignature() > methodWithDeprecated 1`] = ` "test.apidoc.methodWithExample()", ], "since": "", - "sourcePath": "test/scripts/apidoc/signature.example.ts#L278", + "sourcePath": "test/scripts/apidoc/signature.example.ts#L287", "throws": undefined, } `; @@ -250,7 +251,7 @@ exports[`signature > analyzeSignature() > methodWithDeprecatedOption 1`] = ` "returns": "number", "seeAlsos": [], "since": "", - "sourcePath": "test/scripts/apidoc/signature.example.ts#L299", + "sourcePath": "test/scripts/apidoc/signature.example.ts#L308", "throws": undefined, } `; @@ -268,7 +269,7 @@ exports[`signature > analyzeSignature() > methodWithExample 1`] = ` "returns": "number", "seeAlsos": [], "since": "", - "sourcePath": "test/scripts/apidoc/signature.example.ts#L267", + "sourcePath": "test/scripts/apidoc/signature.example.ts#L276", "throws": undefined, } `; @@ -288,7 +289,7 @@ exports[`signature > analyzeSignature() > methodWithMultipleSeeMarkers 1`] = ` "test.apidoc.methodWithDeprecated()", ], "since": "", - "sourcePath": "test/scripts/apidoc/signature.example.ts#L326", + "sourcePath": "test/scripts/apidoc/signature.example.ts#L335", "throws": undefined, } `; @@ -308,7 +309,7 @@ exports[`signature > analyzeSignature() > methodWithMultipleSeeMarkersAndBacktic "test.apidoc.methodWithDeprecated() with parameter <code>bar</code> and <code>baz</code>.", ], "since": "", - "sourcePath": "test/scripts/apidoc/signature.example.ts#L336", + "sourcePath": "test/scripts/apidoc/signature.example.ts#L345", "throws": undefined, } `; @@ -325,7 +326,7 @@ exports[`signature > analyzeSignature() > methodWithSinceMarker 1`] = ` "returns": "number", "seeAlsos": [], "since": "1.0.0", - "sourcePath": "test/scripts/apidoc/signature.example.ts#L345", + "sourcePath": "test/scripts/apidoc/signature.example.ts#L354", "throws": undefined, } `; @@ -342,7 +343,7 @@ exports[`signature > analyzeSignature() > methodWithThrows 1`] = ` "returns": "number", "seeAlsos": [], "since": "", - "sourcePath": "test/scripts/apidoc/signature.example.ts#L287", + "sourcePath": "test/scripts/apidoc/signature.example.ts#L296", "throws": "a Faker error", } `; @@ -491,7 +492,7 @@ It also has a more complex description.</p> "returns": "number", "seeAlsos": [], "since": "", - "sourcePath": "test/scripts/apidoc/signature.example.ts#L217", + "sourcePath": "test/scripts/apidoc/signature.example.ts#L226", "throws": undefined, } `; @@ -530,7 +531,7 @@ exports[`signature > analyzeSignature() > optionsInterfaceParamMethodWithDefault "returns": "number", "seeAlsos": [], "since": "", - "sourcePath": "test/scripts/apidoc/signature.example.ts#L253", + "sourcePath": "test/scripts/apidoc/signature.example.ts#L262", "throws": undefined, } `; @@ -538,7 +539,7 @@ exports[`signature > analyzeSignature() > optionsInterfaceParamMethodWithDefault exports[`signature > analyzeSignature() > optionsParamMethod 1`] = ` { "deprecated": undefined, - "description": "<p>Test with a function parameters.</p> + "description": "<p>Test with an options parameter.</p> ", "examples": "<div class=\\"language-ts\\"><button title=\\"Copy Code\\" class=\\"copy\\"></button><span class=\\"lang\\">ts</span><pre v-pre class=\\"shiki material-theme-palenight\\"><code><span class=\\"line\\"><span style=\\"color:#82AAFF\\">optionsParamMethod</span><span style=\\"color:#BABED8\\">(options: </span><span style=\\"color:#89DDFF\\">{</span></span> <span class=\\"line\\"><span style=\\"color:#BABED8\\"> </span><span style=\\"color:#F07178\\">a</span><span style=\\"color:#89DDFF\\">:</span><span style=\\"color:#BABED8\\"> number</span><span style=\\"color:#89DDFF\\">,</span></span> @@ -552,7 +553,7 @@ exports[`signature > analyzeSignature() > optionsParamMethod 1`] = ` "parameters": [ { "default": undefined, - "description": "<p>The function parameter.</p> + "description": "<p>The options parameter.</p> ", "name": "options", "type": "{ ... }", @@ -596,7 +597,7 @@ exports[`signature > analyzeSignature() > optionsParamMethod 1`] = ` "returns": "number", "seeAlsos": [], "since": "", - "sourcePath": "test/scripts/apidoc/signature.example.ts#L187", + "sourcePath": "test/scripts/apidoc/signature.example.ts#L196", "throws": undefined, } `; @@ -635,7 +636,32 @@ exports[`signature > analyzeSignature() > optionsTypeParamMethodWithDefaults 1`] "returns": "number", "seeAlsos": [], "since": "", - "sourcePath": "test/scripts/apidoc/signature.example.ts#L235", + "sourcePath": "test/scripts/apidoc/signature.example.ts#L244", + "throws": undefined, +} +`; + +exports[`signature > analyzeSignature() > recordParamMethod 1`] = ` +{ + "deprecated": undefined, + "description": "<p>Test with a Record parameter.</p> +", + "examples": "<div class=\\"language-ts\\"><button title=\\"Copy Code\\" class=\\"copy\\"></button><span class=\\"lang\\">ts</span><pre v-pre class=\\"shiki material-theme-palenight\\"><code><span class=\\"line\\"><span style=\\"color:#82AAFF\\">recordParamMethod</span><span style=\\"color:#BABED8\\">(object: Record</span><span style=\\"color:#89DDFF\\"><</span><span style=\\"color:#BABED8\\">string</span><span style=\\"color:#89DDFF\\">,</span><span style=\\"color:#BABED8\\"> number</span><span style=\\"color:#89DDFF\\">></span><span style=\\"color:#BABED8\\">): number</span></span></code></pre> +</div>", + "name": "recordParamMethod", + "parameters": [ + { + "default": undefined, + "description": "<p>The Record parameter.</p> +", + "name": "object", + "type": "Record<string, number>", + }, + ], + "returns": "number", + "seeAlsos": [], + "since": "", + "sourcePath": "test/scripts/apidoc/signature.example.ts#L182", "throws": undefined, } `; diff --git a/test/scripts/apidoc/signature.debug.ts b/test/scripts/apidoc/signature.debug.ts index 52b6976a..d72709b0 100644 --- a/test/scripts/apidoc/signature.debug.ts +++ b/test/scripts/apidoc/signature.debug.ts @@ -11,10 +11,10 @@ import { loadExampleMethods } from './utils'; const methods = loadExampleMethods(); initMarkdownRenderer() - .then(() => { + .then(async () => { for (const [name, method] of Object.entries(methods)) { console.log('Analyzing:', name); - const result = analyzeSignature(method, '', method.name); + const result = await analyzeSignature(method, '', method.name); console.log('Result:', result); } }) diff --git a/test/scripts/apidoc/signature.example.ts b/test/scripts/apidoc/signature.example.ts index a4849e30..724f687d 100644 --- a/test/scripts/apidoc/signature.example.ts +++ b/test/scripts/apidoc/signature.example.ts @@ -175,9 +175,18 @@ export class SignatureTest { } /** - * Test with a function parameters. + * Test with a Record parameter. * - * @param options The function parameter. + * @param object The Record parameter. + */ + recordParamMethod(object: Record<string, number>): number { + return object.a; + } + + /** + * Test with an options parameter. + * + * @param options The options parameter. * @param options.a The number parameter. * @param options.b The string parameter. * @param options.c The boolean parameter. |
