-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
44 lines (39 loc) · 1.38 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
import test from 'ava';
import requireFromString from 'require-from-string';
import fs from 'fs';
import {
buildDefault,
buildWithParser,
buildWithCssModules,
buildCombinedStyles,
buildWithExport
} from './tests/build';
test('test postcss', async t => {
const data = await buildDefault().catch(err => console.log(err.stack));
requireFromString(data);
const styles = window.getComputedStyle(document.body);
t.is(styles.margin, '0px');
});
test('use sugarss as parser', async t => {
const data = await buildWithParser().catch(err => console.log(err.stack));
requireFromString(data);
const styles = window.getComputedStyle(document.body);
t.is(styles.fontSize, '20px');
});
test('use cssmodules', async t => {
const data = await buildWithCssModules().catch(err => console.log(err.stack));
const exported = requireFromString(data);
t.regex(exported.trendy, /trendy_/);
});
test('combine styles', async t => {
const data = await buildCombinedStyles().catch(err => console.log(err.stack));
requireFromString(data);
const styles = window.getComputedStyle(document.body);
t.is(styles.margin, '0px');
t.is(styles.fontSize, '20px');
})
test('extract styles', async t => {
const data = await buildWithExport().catch(err => console.log(err.stack));
const extractedStyles = fs.readFileSync('./tests/output_extract.css');
t.regex(extractedStyles, /color: hotpink;/);
})