-
-
Notifications
You must be signed in to change notification settings - Fork 71
/
rc.test.js
65 lines (55 loc) · 1.8 KB
/
rc.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
const { resolve } = require('node:path')
const { describe, test } = require('node:test')
const { equal } = require('node:assert')
const postcss = require('postcss')
const postcssrc = require('../src/index.js')
const { expected, fixture } = require('./utils.js')
describe('.postcssrc - {Object} - Load Config', () => {
test('Async', () => {
return postcssrc({}, 'test/rc').then(config => {
equal(config.options.parser, require('sugarss'))
equal(config.options.syntax, require('sugarss'))
equal(config.options.map, false)
equal(config.options.from, './test/rc/fixtures/index.css')
equal(config.options.to, './test/rc/expect/index.css')
equal(config.plugins.length, 2)
equal(typeof config.plugins[0], 'function')
equal(typeof config.plugins[1], 'function')
equal(config.file, resolve('test/rc', '.postcssrc'))
})
})
})
test('.postcssrc - {Object} - Process CSS', () => {
let ctx = {
parser: false,
syntax: false
}
return postcssrc(ctx, 'test/rc').then(config => {
return postcss(config.plugins)
.process(fixture('rc', 'index.css'), config.options)
.then(result => {
equal(result.css, expected('rc', 'index.css'))
})
})
})
test('.postcssrc - {Object} - Process SSS', () => {
let ctx = {
from: './test/rc/fixtures/index.sss',
syntax: false
}
return postcssrc(ctx, 'test/rc').then(config => {
return postcss(config.plugins)
.process(fixture('rc', 'index.sss'), config.options)
.then(result => {
equal(result.css, expected('rc', 'index.sss'))
})
})
})
describe('Load Config Error', () => {
test('no config found error', () => {
return postcssrc({}, 'ghostDir')
.catch(error => {
equal(error.message.startsWith("No PostCSS Config found in:"), true)
})
})
})