From 9047b2ec824ae4337479f60fe94f75bd013a89cb Mon Sep 17 00:00:00 2001 From: Bastien Gatellier Date: Mon, 31 Jul 2023 05:58:38 +0200 Subject: [PATCH] test: add 2 tests about a valid parsing of the config CLI option --- .../test-parse-config_2023-07-31-04-08.json | 10 ++++++ .../analysis/AnalysisInputValidation.test.ts | 36 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 common/changes/@fabernovel/heart-common/test-parse-config_2023-07-31-04-08.json diff --git a/common/changes/@fabernovel/heart-common/test-parse-config_2023-07-31-04-08.json b/common/changes/@fabernovel/heart-common/test-parse-config_2023-07-31-04-08.json new file mode 100644 index 00000000..00109bfa --- /dev/null +++ b/common/changes/@fabernovel/heart-common/test-parse-config_2023-07-31-04-08.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@fabernovel/heart-common", + "comment": "", + "type": "none" + } + ], + "packageName": "@fabernovel/heart-common" +} \ No newline at end of file diff --git a/modules/common/tests/validation/input/analysis/AnalysisInputValidation.test.ts b/modules/common/tests/validation/input/analysis/AnalysisInputValidation.test.ts index f0da0bdd..060dc029 100644 --- a/modules/common/tests/validation/input/analysis/AnalysisInputValidation.test.ts +++ b/modules/common/tests/validation/input/analysis/AnalysisInputValidation.test.ts @@ -20,6 +20,42 @@ describe("Invalid option combinations", () => { }) }) +describe("Valid configuration value", () => { + test("JSON object with 1 property", () => { + const { config } = validateAnalysisInput({ config: { url: "" } }) + + expect(config).toStrictEqual({ url: "" }) + }) + + test("JSON object with several properties", () => { + const { config } = validateAnalysisInput({ + config: { + url: "https://heart.fabernovel.com/", + config: { + extends: "lighthouse:default", + settings: { + maxWaitForFcp: 15000, + maxWaitForLoad: 35000, + skipAudits: ["uses-http2", "bf-cache"], + }, + }, + }, + }) + + expect(config).toStrictEqual({ + url: "https://heart.fabernovel.com/", + config: { + extends: "lighthouse:default", + settings: { + maxWaitForFcp: 15000, + maxWaitForLoad: 35000, + skipAudits: ["uses-http2", "bf-cache"], + }, + }, + }) + }) +}) + describe("Invalid configuration value", () => { test("Array", () => { expect(() => {