Skip to content

Commit cb48cdf

Browse files
author
孙美业
committed
test: 添加属性为方法的测试,同步styleMap和proptypes
1 parent 2acec53 commit cb48cdf

3 files changed

Lines changed: 74 additions & 4 deletions

File tree

__tests__/attribute.test.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import React from 'react';
2-
import {
3-
Text, View
1+
2+
import {acssPropTypes
43
} from '../lib/index';
54
import styleMap from "../lib/styleMap";
65

@@ -40,3 +39,12 @@ describe("Attribute",()=>{
4039
})
4140
}
4241
})
42+
describe("map stylemap to proptypes",()=>{
43+
it("is proptypes sync with stylemap",()=>{
44+
45+
for(let i in styleMap){
46+
expect(acssPropTypes[i] instanceof Function).toBe(true)
47+
}
48+
49+
})
50+
})

__tests__/report.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
passed function attribute p padding四个方向 p padding四个方向
2+
passed function attribute m margin4个方法向 m margin4个方法向
3+
passed function attribute pr 两种可能 —— position:relative pr 两种可能 —— position:relative
4+
passed function attribute pr 两种可能 —— padding-right pr 两种可能 —— padding-right
15
passed CusText CusText正常渲染 CusText正常渲染
26
passed CusText CusText Acss 样式渲染 CusText Acss 样式渲染
37
passed CusView CusView正常渲染 CusView正常渲染
@@ -52,4 +56,5 @@ passed Attribute pv pv
5256
passed Attribute r r
5357
passed Attribute t t
5458
passed Attribute w w
55-
passed Attribute zi zi
59+
passed Attribute zi zi
60+
passed map stylemap to proptypes is proptypes sync with stylemap is proptypes sync with stylemap

__tests__/sattr.test.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React from 'react';
2+
import {
3+
Text, View, ImageBackground, Image,
4+
} from '../lib/index';
5+
import {shallow,mount} from 'enzyme';
6+
7+
/**
8+
* 此处测试方法的属性
9+
*/
10+
describe("function attribute",()=>{
11+
it("p padding四个方向",()=>{
12+
const expectRes={
13+
paddingTop:40,
14+
paddingLeft:40,
15+
paddingBottom:40,
16+
paddingRight:40
17+
}
18+
const tmp=shallow(<View p={40}></View>)
19+
const style=tmp.prop("style")
20+
for(let i in style){
21+
expect(style[i]).toBe(expectRes[i])
22+
}
23+
})
24+
it("m margin4个方法向",()=>{
25+
const expectRes={
26+
marginTop:40,
27+
marginLeft:40,
28+
marginBottom:40,
29+
marginRight:40
30+
}
31+
const tmp=shallow(<View m={40}></View>)
32+
const style=tmp.prop("style")
33+
for(let i in style){
34+
expect(style[i]).toBe(expectRes[i])
35+
}
36+
})
37+
it("pr 两种可能 —— position:relative",()=>{
38+
const expectRes={
39+
position:"relative"
40+
}
41+
const tmp=shallow(<View pr></View>)
42+
const style=tmp.prop("style")
43+
for(let i in style){
44+
expect(style[i]).toBe(expectRes[i])
45+
}
46+
})
47+
it("pr 两种可能 —— padding-right",()=>{
48+
const expectRes={
49+
paddingRight:40
50+
}
51+
const tmp=shallow(<View pr={40}></View>)
52+
const style=tmp.prop("style")
53+
for(let i in style){
54+
expect(style[i]).toBe(expectRes[i])
55+
}
56+
})
57+
})

0 commit comments

Comments
 (0)