-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.js
65 lines (60 loc) · 2.14 KB
/
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
import postcss from 'postcss';
import test from "ava";
import {readFile as read} from "fs";
function createStringFromFile (fileName) {
return new Promise (function(resolve, reject) {
read(fileName, (err, data) => {
if (err) throw err;
// Split the buffer to remove the comment that was added
var theExport = data.slice(0, 32);
const out = theExport.toString("utf-8");
resolve();
});
});
}
test("Has access to options and extractor values", async t => {
return postcss()
.use(require("postcss-extract-to-file")({
"remaining": "___tests___/remaining.css",
"extracted": "___tests___/extracted.css",
"extractors": [
".no-flex"
]
}))
});
test("Check actual extracted CSS matches the expected extracted CSS", t => {
const inputCSS = ".normal { width: 100%; } .no-flex .normal { width: 50%; }";
return postcss()
.use(require("postcss-extract-to-file")({
"remaining": "___tests___/remaining.css",
"extracted": "___tests___/extracted.css",
"extractors": [
".no-flex"
]
}))
.process(inputCSS).then(function(){
createStringFromFile("___tests___/extracted.css").then(function(result) {
t.same(result, ".no-flex .normal { width: 50%; }", "output in extracted file differs from expected");
});
});
});
test("Check actual remaining CSS matches the expected remaining CSS", t => {
const inputCSS = ".normal { width: 100%; } .no-flex .normal { width: 50%; }";
return postcss()
.use(require("postcss-extract-to-file")({
"remaining": "___tests___/remaining.css",
"extracted": "___tests___/extracted.css",
"extractors": [
".no-flex"
]
}))
.process(inputCSS).then(function(){
createStringFromFile("___tests___/remaining.css").then(function(result) {
t.same(result, ".normal { width: 100%; }", "output in remaining file differs from expected");
});
});
});
test('can access PostCSS version', t => {
var ver = postcss().version;
t.ok(ver, 'should be able to access version');
});