@codecovevienna/gittt-cli
Version:
Tracking time with CLI into a git repository
48 lines (36 loc) • 1.34 kB
text/typescript
import { assert } from "chai";
import { CommanderStatic } from "commander";
import proxyquire from "proxyquire";
import sinon from "sinon";
import { App } from "../../app";
import { emptyHelper } from "../helper";
describe("Start test", function () {
before(function () {
proxyquire.noCallThru();
});
it("should start time tracking", async function () {
const mockedCommander: CommanderStatic = proxyquire("commander", {});
const mockedHelper: any = Object.assign({}, emptyHelper);
const startTimerStub = sinon.stub().resolves();
mockedHelper.FileHelper = class {
public static getHomeDir = sinon.stub().returns("/home/test");
}
mockedHelper.ConfigHelper = class {
public static instance: any;
public static getInstance(): any { if (!this.instance) { this.instance = new this() } return this.instance }
public isInitialized = sinon.stub().resolves(true);
}
mockedHelper.TimerHelper = class {
public startTimer = startTimerStub;
}
const proxy: any = proxyquire("../../app", {
"./helper": mockedHelper,
"commander": mockedCommander,
});
const mockedApp: App = new proxy.App();
await mockedApp.setup();
process.argv = ["namespace", "mocked", "start"];
mockedApp.start();
assert.isTrue(startTimerStub.called);
});
});