-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.test.js
78 lines (68 loc) · 1.94 KB
/
index.test.js
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
const path = require("path");
const fs = require("fs");
const shell = require("shelljs");
const { spawnRegistry } = require("./helper/registry");
const rimraf = require("rimraf");
const tmp = require("tmp");
const { runCli } = require("./helper/cli");
const { tag } = require("../versions");
const publish = require("../publish");
shell.config.fatal = true;
jest.setTimeout(400000);
const registryUrl = "http://localhost:4873/";
describe("E2E cssnano ", () => {
let childFork;
beforeAll(async () => {
childFork = await spawnRegistry();
try {
await publish(registryUrl);
} catch (error) {
throw new Error(error);
}
});
afterAll(() => {
if (childFork) {
childFork.kill();
}
rimraf.sync("cssnano");
});
it("should install the latest nightly version" + tag, async done => {
expect(
shell.exec("npm install cssnano@" + tag + " --registry " + registryUrl)
.code
).toBe(0);
done();
});
it("should install the latest nightly tag", async done => {
expect(
shell.exec("npm install cssnano@nightly --registry " + registryUrl).code
).toBe(0);
done();
});
it(
"should minify the input using postcss cli and cssnano" + tag,
async done => {
await shell.cd(__dirname + "/fixture");
await shell.exec(
"npm install cssnano@" + tag + " --registry " + registryUrl
);
const cmdOutput = await runCli(
path.resolve(__dirname, "../node_modules", ".bin", "postcss"),
[
path.resolve(__dirname, "./fixture/input.css"),
"-o",
path.resolve(__dirname, "./fixture/output.css")
]
);
expect(
fs.existsSync(path.resolve(__dirname, "./fixture/output.css"))
).toBe(true);
const outputCode = fs.readFileSync(
path.resolve(__dirname, "./fixture/output.css"),
"utf-8"
);
expect(outputCode.split("\n").length).toBe(1);
done();
}
);
});