-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathpost-install.ts
59 lines (46 loc) · 2.05 KB
/
post-install.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { Yok } from "../../lib/common/yok";
import { assert } from "chai";
import { PostInstallCliCommand } from "../../lib/commands/post-install";
const createTestInjector = (): IInjector => {
const testInjector = new Yok();
testInjector.register("fs", {
setCurrentUserAsOwner: async (path: string, owner: string): Promise<void> => undefined
});
testInjector.register("subscriptionService", {
subscribeForNewsletter: async (): Promise<void> => undefined
});
testInjector.register("staticConfig", {});
testInjector.register("commandsService", {
tryExecuteCommand: async (commandName: string, commandArguments: string[]): Promise<void> => undefined
});
testInjector.register("htmlHelpService", {
generateHtmlPages: async (): Promise<void> => undefined
});
testInjector.register("options", {});
testInjector.register("doctorService", {
printWarnings: async (configOptions?: { trackResult: boolean }): Promise<boolean> => undefined
});
testInjector.register("analyticsService", {
checkConsent: async (): Promise<void> => undefined,
track: async (featureName: string, featureValue: string): Promise<void> => undefined
});
testInjector.register("logger", {
out: (formatStr?: any, ...args: any[]): void => undefined,
printMarkdown: (...args: any[]): void => undefined
});
testInjector.registerCommand("post-install-cli", PostInstallCliCommand);
return testInjector;
};
describe("post-install command", () => {
it("calls subscriptionService.subscribeForNewsletter method", async () => {
const testInjector = createTestInjector();
const subscriptionService = testInjector.resolve<ISubscriptionService>("subscriptionService");
let isSubscribeForNewsletterCalled = false;
subscriptionService.subscribeForNewsletter = async (): Promise<void> => {
isSubscribeForNewsletterCalled = true;
};
const postInstallCommand = testInjector.resolveCommand("post-install-cli");
await postInstallCommand.execute([]);
assert.isTrue(isSubscribeForNewsletterCalled, "post-install-cli command must call subscriptionService.subscribeForNewsletter");
});
});