Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Add test to append variable group
Browse files Browse the repository at this point in the history
  • Loading branch information
Edaena Salinas authored and Edaena Salinas committed Apr 23, 2020
1 parent cf41bc8 commit 516db8d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/commands/project/append-variable-group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,33 @@ describe("Test execute function", () => {
expect(exitFn).toBeCalledTimes(1);
expect(exitFn.mock.calls).toEqual([[1]]);
});
it("variable group does not exist", async () => {
const exitFn = jest.fn();
spyOn(fileutils, "appendVariableGroupToPipelineYaml");
jest
.spyOn(appendVariableGrp, "variableGroupExists")
.mockReturnValueOnce(Promise.resolve(false));

const bedrockFile = createTestBedrockYaml(false) as BedrockFile;

jest.spyOn(config, "Bedrock").mockReturnValue(bedrockFile as BedrockFile);
jest.spyOn(appendVariableGrp, "checkDependencies").mockReturnValueOnce();
jest
.spyOn(appendVariableGrp, "validateValues")
.mockReturnValueOnce(mockValues as ConfigValues);
jest.spyOn(bedrockYaml, "addVariableGroup").mockReturnValue();
jest
.spyOn(fileutils, "appendVariableGroupToPipelineYaml")
.mockReturnValue();

expect(bedrockFile.variableGroups?.length).toBe(0);
await execute("my-path", "my-vg", mockValues, exitFn);
expect(exitFn).toBeCalledTimes(1);
expect(exitFn.mock.calls).toEqual([[1]]);
expect(fileutils.appendVariableGroupToPipelineYaml).toHaveBeenCalledTimes(
0
);
});
it("appends variable group", async () => {
const exitFn = jest.fn();
spyOn(fileutils, "appendVariableGroupToPipelineYaml");
Expand Down

0 comments on commit 516db8d

Please sign in to comment.