diff options
| author | renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> | 2022-06-29 09:11:42 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-06-29 09:11:42 +0200 |
| commit | 4aa4960832aefaa0358c238229af16232a03e431 (patch) | |
| tree | 1a073de3adef83705b59bbab5bbf50807b63ef69 /test/scripts | |
| parent | f35636001eb67df120f4c3c7746a015f1150c0d8 (diff) | |
| download | faker-4aa4960832aefaa0358c238229af16232a03e431.tar.xz faker-4aa4960832aefaa0358c238229af16232a03e431.zip | |
chore(deps): update doc-dependencies (#1110)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: ST-DDT <[email protected]>
Diffstat (limited to 'test/scripts')
| -rw-r--r-- | test/scripts/apidoc/examplesAndDeprecations.spec.ts | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/test/scripts/apidoc/examplesAndDeprecations.spec.ts b/test/scripts/apidoc/examplesAndDeprecations.spec.ts index 87669d6b..314e72d4 100644 --- a/test/scripts/apidoc/examplesAndDeprecations.spec.ts +++ b/test/scripts/apidoc/examplesAndDeprecations.spec.ts @@ -4,6 +4,10 @@ import type { DeclarationReflection, SignatureReflection } from 'typedoc'; import { ReflectionKind } from 'typedoc'; import type { SpyInstance } from 'vitest'; import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest'; +import { + extractRawExamples, + isDeprecated, +} from '../../../scripts/apidoc/utils'; import { faker } from '../../../src'; import { loadProject } from './utils'; @@ -67,16 +71,11 @@ describe('examples and deprecations', () => { // eslint-disable-next-line @typescript-eslint/no-misused-promises it.each(Object.entries(methodsByName))('%s', async (methodName, method) => { const signatures: SignatureReflection[] = - method.signatures || method.type['declaration'].signatures; + method.signatures || method.type?.['declaration'].signatures; const signature = signatures[signatures.length - 1]; // Extract examples and make them runnable - let examples = - signature?.comment?.tags - .filter((tag) => tag.tagName === 'example') - .map((tag) => tag.text.trimEnd()) - .join('') - .trim() ?? ''; + let examples = extractRawExamples(signature).join('').trim() ?? ''; examples = examples.replace( /faker([A-Z]{2})\./g, (_, locale: string) => `faker.locale = '${locales[locale]}';\nfaker.` @@ -99,7 +98,7 @@ describe('examples and deprecations', () => { await import(path); // Verify logging - const deprecatedFlag = signature.comment?.hasTag('deprecated') ?? false; + const deprecatedFlag = isDeprecated(signature); if (deprecatedFlag) { expect(consoleSpies[1]).toHaveBeenCalled(); } else { |
