From 51de1c5f726ac5b039b25a93e7e57cca61062d3b Mon Sep 17 00:00:00 2001 From: Edaena Salinas Date: Thu, 23 Apr 2020 14:51:32 -0700 Subject: [PATCH] Update unit tests --- .../project/append-variable-group.test.ts | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/commands/project/append-variable-group.test.ts b/src/commands/project/append-variable-group.test.ts index 9348e891..51e66670 100644 --- a/src/commands/project/append-variable-group.test.ts +++ b/src/commands/project/append-variable-group.test.ts @@ -1,4 +1,8 @@ -import { execute, CommandOptions } from "./append-variable-group"; +import { + execute, + CommandOptions, + validateValues, +} from "./append-variable-group"; import * as appendVariableGrp from "./append-variable-group"; import * as fileutils from "../../lib/fileutils"; import { createTestBedrockYaml } from "../../test/mockFactory"; @@ -7,6 +11,7 @@ import { BedrockFile } from "../../types"; import { ConfigValues } from "./pipeline"; import * as bedrockYaml from "../../lib/bedrockYaml"; import * as variableGrp from "../../lib/pipelines/variableGroup"; +import { deepClone } from "../../lib/util"; const mockValues: CommandOptions = { devopsProject: "azDoProject", @@ -76,3 +81,23 @@ describe("Test execute function", () => { ); }); }); +describe("test validateValues function", () => { + it("valid org and project name", () => { + const data = deepClone(mockValues); + validateValues(data); + }); + it("invalid project name", () => { + const data = deepClone(mockValues); + data.devopsProject = "project\\abc"; + expect(() => { + validateValues(data); + }).toThrow(); + }); + it("invalid org name", () => { + const data = deepClone(mockValues); + data.orgName = "org name"; + expect(() => { + validateValues(data); + }).toThrow(); + }); +});