-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.test.js
73 lines (60 loc) · 2.71 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
var postcss = require('postcss')
var plugin = require('./')
function run (input, output, opts) {
return postcss([plugin(opts)]).
process(input, {from: undefined}).
then(result => {
expect(result.css).toEqual(output)
expect(result.warnings().length).toBe(0)
})
}
describe('不传任何配置', () => {
it('不传任何配置', () => {
return run(`h1 {margin: 0 0 20px;font-size: 40px;line-height: 1.2;}`,
`h1 {margin: 0 0 20rpx;font-size: 40rpx;line-height: 1.2;}`)
})
})
describe('platform 为 weapp', () => {
it('{platform: \'weapp\', designWidth: 750} ', () => {
return run(`h1 {margin: 0 0 20px;font-size: 40px;line-height: 1.2;}`,
`h1 {margin: 0 0 20rpx;font-size: 40rpx;line-height: 1.2;}`,
{platform: 'weapp', designWidth: 750})
})
it('{platform: \'weapp\', designWidth: 750} ', () => {
return run(`h1 {margin: 0 0 20Px;font-size: 40PX;line-height: 1.2;}`,
`h1 {margin: 0 0 20Px;font-size: 40PX;line-height: 1.2;}`,
{platform: 'weapp', designWidth: 750})
})
it(' {designWidth: 750, rootValue: 10} ', () => {
return run(`h1 {margin: 0 0 20px;font-size: 40px;line-height: 1.2;}`,
`h1 {margin: 0 0 2rpx;font-size: 4rpx;line-height: 1.2;}`,
{platform: 'weapp', designWidth: 750, rootValue: '10'})
})
it(' {designWidth: 640, rootValue: 40} ', () => {
return run(`h1 {margin: 0 0 20px;font-size: 40px;line-height: 1.2;}`,
`h1 {margin: 0 0 1.7095rpx;font-size: 3.4189rpx;line-height: 1.2;}`,
{platform: 'weapp', designWidth: 640, rootValue: '10'})
})
})
describe('platform 为 h5', () => {
it('{designWidth: 750}', () => {
return run(`h1 {margin: 0 0 20px;font-size: 40px;line-height: 1.2;}`,
`h1 {margin: 0 0 0.5rem;font-size: 1rem;line-height: 1.2;}`,
{platform: 'h5', designWidth: 750})
})
it('{designWidth: 750}', () => {
return run(`h1 {margin: 0 0 20Px;font-size: 40PX;line-height: 1.2;}`,
`h1 {margin: 0 0 20Px;font-size: 40PX;line-height: 1.2;}`,
{platform: 'h5', designWidth: 750})
})
it(' {designWidth: 750, rootValue: 10} ', () => {
return run(`h1 {margin: 0 0 20px;font-size: 40px;line-height: 1.2;}`,
`h1 {margin: 0 0 2rem;font-size: 4rem;line-height: 1.2;}`,
{platform: 'h5', designWidth: 750, rootValue: 10})
})
it(' {designWidth: 640, rootValue: 40} ', () => {
return run(`h1 {margin: 0 0 20px;font-size: 40px;line-height: 1.2;}`,
`h1 {margin: 0 0 0.5rem;font-size: 1rem;line-height: 1.2;}`,
{platform: 'h5', designWidth: 640, rootValue: 40})
})
})