Skip to content

Commit

Permalink
✅ Test activation flow of git mob
Browse files Browse the repository at this point in the history
Ensure git mob cli install options are provided when it is not detected.

#44
  • Loading branch information
rkotze committed Oct 18, 2020
1 parent bcbce85 commit 3c43002
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
43 changes: 43 additions & 0 deletions extension.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const { activate } = require("./extension");
const { mob } = require("./src/git/commands");
const { setupGitMob } = require("./src/setup-git-mob");
const { waitForRepos } = require("./src/wait-for-repos");
const { installCli } = require("./src/commands/install-cli");
const { setContextNotInstalled } = require("./src/set-context/notInstalled");

jest.mock("./src/git/commands");
jest.mock("./src/setup-git-mob");
jest.mock("./src/vscode-git-extension/git-ext");
jest.mock("./src/wait-for-repos");
jest.mock("./src/commands/install-cli");
jest.mock("./src/set-context/notInstalled");

describe("Activate Git Mob extension", function () {
beforeAll(() => {
waitForRepos.mockImplementation((_git, callback) => {
callback();
});

installCli.mockImplementation((_context, callback) => {
callback();
});
});

it("cli not installed provide install options", function () {
mob.gitMobLatest.mockReturnValue(1);
activate();

expect(setContextNotInstalled).nthCalledWith(1, true);
expect(installCli).toBeCalledTimes(1);
expect(setContextNotInstalled).nthCalledWith(2, false);
expect(setupGitMob).toBeCalledTimes(1);
});

it("cli is installed call setup", function () {
mob.gitMobLatest.mockReturnValue(0);
activate();

expect(installCli).not.toBeCalled();
expect(setupGitMob).toBeCalledTimes(1);
});
});
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
clearMocks: true,
};

0 comments on commit 3c43002

Please sign in to comment.