generated from AnandChowdhary/node.ts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.spec.ts
93 lines (83 loc) · 2.47 KB
/
index.spec.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { carpent, getLicenseText } from "./index";
import { pathExists, readFile, readJson, remove } from "fs-extra";
import { join } from "path";
describe("carpent", () => {
beforeAll(async () => {
await carpent({
repo: "https://github.com/AnandChowdhary/carpent",
dir: "example",
name: "example-project",
license: "ISC License",
licenseName: "Anand Chowdhary",
pushAccess: "Do nothing, I'll initialize the repository myself",
});
}, 30000);
afterAll(async () => {
await remove(join(".", "example"));
}, 5000);
it("creates folder", async () => {
expect(await pathExists(join(".", "example"))).toBeTruthy();
});
it("clones correct repository", async () => {
expect(
(await readFile(join(".", "example", "index.ts"), "utf8")).includes(
"Carpent"
)
).toBeTruthy();
});
it("sets license in package.json", async () => {
expect(
(await readJson(join(".", "example", "package.json"))).license === "ISC"
).toBeTruthy();
});
it("sets name in package.json", async () => {
expect(
(await readJson(join(".", "example", "package.json"))).name ===
"example-project"
).toBeTruthy();
});
it("creates LICENSE file", async () => {
expect(
(await readFile(join(".", "example", "LICENSE"), "utf8")).includes(
"ISC License"
)
).toBeTruthy();
});
it("sets current year in LICENSE", async () => {
expect(
(await readFile(join(".", "example", "LICENSE"), "utf8")).includes(
new Date().getFullYear().toString()
)
).toBeTruthy();
});
it("sets full name in LICENSE", async () => {
expect(
(await readFile(join(".", "example", "LICENSE"), "utf8")).includes(
"Anand Chowdhary"
)
).toBeTruthy();
});
});
describe("license fetcher", () => {
it("fetches MIT license", async () => {
expect(
(await getLicenseText("MIT")).includes(
"Permission is hereby granted, free of charge, to any person obtaining a copy"
)
).toBeTruthy();
});
it("fetches ISC license", async () => {
expect(
(await getLicenseText("ISC")).includes(
"Permission to use, copy, modify, and/or distribute this software for any"
)
).toBeTruthy();
});
it("fetches CC BY 4.0 license", async () => {
expect(
(await getLicenseText("CC-BY-4.0")).includes(
"By exercising the Licensed Rights (defined below), You accept and agree"
)
).toBeTruthy();
});
});