From 6d6402a9748563c238187ab873fbdcb7395ccaa0 Mon Sep 17 00:00:00 2001 From: Juan Escalada Date: Tue, 26 Nov 2024 12:17:58 +0900 Subject: [PATCH] Fix tests Signed-off-by: Juan Escalada --- .../commands/api-reports/api-reports.test.ts | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/packages/repo-tools/src/commands/api-reports/api-reports.test.ts b/packages/repo-tools/src/commands/api-reports/api-reports.test.ts index 6401f64439..94ae42d715 100644 --- a/packages/repo-tools/src/commands/api-reports/api-reports.test.ts +++ b/packages/repo-tools/src/commands/api-reports/api-reports.test.ts @@ -323,6 +323,24 @@ describe('buildApiReports', () => { expect(buildDocs).not.toHaveBeenCalled(); }); + it('should throw an error if a path does not exist', async () => { + const paths = ['packages/package-a', 'packages/package-c']; + const opts = {}; + + await expect(buildApiReports(paths, opts)).rejects.toThrow( + 'Invalid paths provided: packages/package-c', + ); + }); + it('should throw an error if an option is malformed', async () => { + const paths = ['ae-undocumented']; + const opts = { + omitMessages: 'ae-wrong-input-file-type,', + }; + + await expect(buildApiReports(paths, opts)).rejects.toThrow( + 'Invalid paths provided: ae-undocumented', + ); + }); }); describe('allowWarnings', () => { it('should accept single path value', async () => { @@ -473,17 +491,6 @@ describe('buildApiReports', () => { outputDir: mockDir.resolve('node_modules/.cache/api-extractor'), }); }); - - it('should throw an error if omitMessages ends with a comma', async () => { - const opts = { - omitMessages: 'ae-missing-release-tag,', - }; - const paths = ['packages/*']; - - await expect(buildApiReports(paths, opts)).rejects.toThrow( - `Invalid value for --omit-messages: ${opts.omitMessages}\nMust be a comma-separated list of strings without spaces or wrapped in quotations.`, - ); - }); }); describe('isCI', () => { it('should set localBuild to false if CI option is passed', async () => {