@@ -25,155 +25,159 @@ describe('tests button', () => {
25
25
} )
26
26
27
27
it ( 'should the component has two tags' , ( ) => {
28
- expect ( Object . keys ( docButton [ 'tags' ] ) . length ) . toEqual ( 2 )
29
- } )
30
-
31
- it ( 'should give the component a size prop with default value to "normal"' , ( ) => {
32
- expect ( docButton [ 'props' ] [ 'size' ] [ 'defaultValue' ] [ 'value' ] ) . toEqual ( '"normal"' )
33
- } )
34
-
35
- it ( 'should the component has size prop description equal The size of the button' , ( ) => {
36
- expect ( docButton [ 'props' ] [ 'size' ] [ 'description' ] ) . toEqual ( 'The size of the button' )
37
- } )
38
-
39
- it ( 'should the component has color prop description equal The color for the button example' , ( ) => {
40
- expect ( docButton [ 'props' ] [ 'color' ] [ 'description' ] ) . toEqual ( 'The color for the button example' )
41
- } )
42
-
43
- it ( 'should the component has color prop default equal #333' , ( ) => {
44
- expect ( docButton [ 'props' ] [ 'color' ] [ 'defaultValue' ] [ 'value' ] ) . toEqual ( '"#333"' )
28
+ expect ( Object . keys ( docButton . tags ) . length ) . toEqual ( 2 )
45
29
} )
46
30
47
31
it ( 'should the component has authors' , ( ) => {
48
- expect ( typeof docButton [ ' tags' ] [ ' author' ] !== 'undefined' ) . toBe ( true )
32
+ expect ( docButton . tags . author ) . not . toBeUndefined ( )
49
33
} )
50
34
51
35
it ( 'should not see the method without tag @public' , ( ) => {
52
- expect ( docButton [ ' methods' ] . length ) . toEqual ( 0 )
36
+ expect ( docButton . methods . length ) . toEqual ( 0 )
53
37
} )
54
38
55
39
it ( 'should have props' , ( ) => {
56
- expect ( typeof docButton [ ' props' ] !== 'undefined' ) . toBe ( true )
40
+ expect ( docButton . props ) . not . toBeUndefined ( )
57
41
} )
58
42
59
43
it ( 'should the component has version' , ( ) => {
60
- expect ( typeof docButton [ 'tags' ] [ 'version' ] !== 'undefined' ) . toBe ( true )
61
- } )
44
+ expect ( docButton . tags . version ) . not . toBeUndefined ( )
45
+ } )
46
+ describe ( 'props' , ( ) => {
47
+ let props
48
+
49
+ beforeAll ( ( ) => {
50
+ props = docButton . props ? docButton . props : { }
51
+ } )
52
+ it ( 'should give the component a size prop with default value to "normal"' , ( ) => {
53
+ expect ( props . size . defaultValue ) . toMatchObject ( { value : '"normal"' } )
54
+ } )
55
+
56
+ it ( 'should the component has size prop description equal The size of the button' , ( ) => {
57
+ expect ( props . size . description ) . toEqual ( 'The size of the button' )
58
+ } )
62
59
63
- it ( 'should the component has fourteen props ' , ( ) => {
64
- expect ( Object . keys ( docButton [ ' props' ] ) . length ) . toEqual ( 14 )
65
- } )
60
+ it ( 'should the component has color prop description equal The color for the button example ' , ( ) => {
61
+ expect ( props . color . description ) . toEqual ( 'The color for the button example' )
62
+ } )
66
63
67
- it ( 'should the component has propsAnother prop default equal \'blue\'' , ( ) => {
68
- expect ( docButton [ 'props' ] [ 'propsAnother' ] [ 'defaultValue' ] [ 'value' ] ) . toEqual ( '"blue"' )
69
- } )
64
+ it ( 'should the component has color prop default equal #333' , ( ) => {
65
+ expect ( props . color . defaultValue ) . toMatchObject ( { value : '"#333"' } )
66
+ } )
67
+ it ( 'should the component has fourteen props' , ( ) => {
68
+ expect ( Object . keys ( props ) . length ) . toEqual ( 14 )
69
+ } )
70
70
71
- it ( 'should span to be string|number ' , ( ) => {
72
- expect ( docButton [ ' props' ] [ 'span' ] [ 'type' ] [ 'name' ] ) . toEqual ( 'string|number' )
73
- } )
71
+ it ( 'should the component has propsAnother prop default equal "blue" ' , ( ) => {
72
+ expect ( props . propsAnother . defaultValue ) . toMatchObject ( { value : '"blue"' } )
73
+ } )
74
74
75
- it ( "should span has as description 'Number of columns (1-12) the column should span.'" , ( ) => {
76
- expect ( docButton [ 'props' ] [ 'span' ] [ 'description' ] ) . toEqual (
77
- 'Number of columns (1-12) the column should span.'
78
- )
79
- } )
75
+ it ( 'should span to be string|number' , ( ) => {
76
+ expect ( props . span . type ) . toEqual ( { name : 'string|number' } )
77
+ } )
80
78
81
- it ( "should span has as description 'Sm breakpoint and above '" , ( ) => {
82
- expect ( docButton [ ' props' ] [ 'spanSm' ] [ ' description' ] ) . toEqual ( 'Sm breakpoint and above ' )
83
- } )
79
+ it ( "should span has as description 'Number of columns (1-12) the column should span. '" , ( ) => {
80
+ expect ( props . span . description ) . toEqual ( 'Number of columns (1-12) the column should span. ' )
81
+ } )
84
82
85
- it ( "should spanMd has as description 'Md breakpoint and above'" , ( ) => {
86
- expect ( docButton [ ' props' ] [ 'spanMd' ] [ ' description' ] ) . toEqual ( 'Md breakpoint and above' )
87
- } )
83
+ it ( "should span has as description 'Sm breakpoint and above'" , ( ) => {
84
+ expect ( props . spanSm . description ) . toEqual ( 'Sm breakpoint and above' )
85
+ } )
88
86
89
- it ( ' should spanSm to be string|number' , ( ) => {
90
- expect ( docButton [ ' props' ] [ 'spanSm' ] [ 'type' ] [ 'name' ] ) . toEqual ( 'string|number ' )
91
- } )
87
+ it ( " should spanMd has as description 'Md breakpoint and above'" , ( ) => {
88
+ expect ( props . spanMd . description ) . toEqual ( 'Md breakpoint and above ' )
89
+ } )
92
90
93
- it ( 'should set funcDefault prop as a function (type "func") ' , ( ) => {
94
- expect ( docButton [ ' props' ] [ 'funcDefault' ] [ ' type' ] [ 'name' ] ) . toEqual ( 'func' )
95
- } )
91
+ it ( 'should spanSm to be string|number ' , ( ) => {
92
+ expect ( props . spanSm . type ) . toEqual ( { name : 'string|number' } )
93
+ } )
96
94
97
- it ( 'should prop1 to be string ' , ( ) => {
98
- expect ( docButton [ ' props' ] [ 'prop1' ] [ ' type' ] ) . toMatchObject ( { name :'string' } )
99
- } )
95
+ it ( 'should set funcDefault prop as a function (type "func") ' , ( ) => {
96
+ expect ( props . funcDefault . type ) . toEqual ( { name : 'func' } )
97
+ } )
100
98
101
- it ( 'should example to be boolean ' , ( ) => {
102
- expect ( docButton [ ' props' ] [ 'example' ] [ ' type' ] [ 'name' ] ) . toEqual ( 'boolean' )
103
- } )
99
+ it ( 'should prop1 to be string ' , ( ) => {
100
+ expect ( props . prop1 . type ) . toMatchObject ( { name : 'string' } )
101
+ } )
104
102
105
- it ( 'should value default example to be false ' , ( ) => {
106
- expect ( docButton [ ' props' ] [ ' example' ] [ 'defaultValue' ] [ 'value' ] ) . toEqual ( 'false' )
107
- } )
103
+ it ( 'should example to be boolean ' , ( ) => {
104
+ expect ( props . example . type ) . toEqual ( { name : 'boolean' } )
105
+ } )
108
106
109
- it ( 'should value default example props description to be The example props ' , ( ) => {
110
- expect ( docButton [ ' props' ] [ ' example' ] [ 'description' ] ) . toEqual ( 'The example props' )
111
- } )
107
+ it ( 'should value default example to be false ' , ( ) => {
108
+ expect ( props . example . defaultValue ) . toMatchObject ( { value : 'false' } )
109
+ } )
112
110
113
- it ( 'should v-model to be string ' , ( ) => {
114
- expect ( docButton [ ' props' ] [ 'v-model' ] [ 'type' ] [ 'name' ] ) . toEqual ( 'string ' )
115
- } )
111
+ it ( 'should value default example props description to be The example props ' , ( ) => {
112
+ expect ( props . example . description ) . toEqual ( 'The example props ' )
113
+ } )
116
114
117
- it ( 'should value default v-model to be example model ' , ( ) => {
118
- expect ( docButton [ ' props' ] [ 'v-model' ] [ 'defaultValue' ] [ 'value' ] ) . toEqual ( '"example model"' )
119
- } )
115
+ it ( 'should v-model to be string ' , ( ) => {
116
+ expect ( props [ 'v-model' ] . type ) . toEqual ( { name : 'string' } )
117
+ } )
120
118
121
- it ( 'should value default v-model props description to be Model example2 ' , ( ) => {
122
- expect ( docButton [ ' props' ] [ 'v-model' ] [ 'description' ] ) . toEqual ( 'Model example2' )
123
- } )
119
+ it ( 'should value default v-model to be example model ' , ( ) => {
120
+ expect ( props [ 'v-model' ] . defaultValue ) . toMatchObject ( { value : '"example model"' } )
121
+ } )
124
122
125
- it ( 'should propE to be string ' , ( ) => {
126
- expect ( docButton [ ' props' ] [ 'propE' ] [ 'type' ] [ 'name' ] ) . toEqual ( 'object ' )
127
- } )
123
+ it ( 'should value default v-model props description to be Model example2 ' , ( ) => {
124
+ expect ( props [ 'v-model' ] . description ) . toEqual ( 'Model example2 ' )
125
+ } )
128
126
129
- it ( 'should value default propE to be a funtion' , ( ) => {
130
- const functionNoSpaceNoReturn = docButton [ 'props' ] [ 'propE' ] [ 'defaultValue' ] [ 'value' ] . replace ( / [ \n \r ] / g, '' )
131
- expect ( functionNoSpaceNoReturn ) . toEqual ( `()=>{return{message:'hello'};}` )
132
- expect ( docButton [ 'props' ] [ 'propE' ] [ 'defaultValue' ] [ 'func' ] ) . toBeTruthy ( )
133
- } )
127
+ it ( 'should propE to be string' , ( ) => {
128
+ expect ( props . propE . type ) . toEqual ( { name : 'object' } )
129
+ } )
134
130
135
- it ( 'should example3 to be number' , ( ) => {
136
- expect ( docButton [ 'props' ] [ 'example3' ] ) . toMatchObject ( { type :{ name :'number' } } )
137
- } )
131
+ it ( 'should value default propE to be a funtion' , ( ) => {
132
+ const dv = props . propE . defaultValue
133
+ const functionNoSpaceNoReturn = dv ? dv . value . replace ( / [ \n \r ] / g, '' ) : ''
134
+ expect ( functionNoSpaceNoReturn ) . toEqual ( `()=>{return{message:'hello'};}` )
135
+ expect ( dv ? dv . func : false ) . toBeTruthy ( )
136
+ } )
138
137
139
- it ( 'should value default example3 to be 16 ' , ( ) => {
140
- expect ( docButton [ ' props' ] [ ' example3' ] [ 'defaultValue' ] [ 'value' ] ) . toEqual ( '16' )
141
- } )
138
+ it ( 'should example3 to be number ' , ( ) => {
139
+ expect ( props . example3 ) . toMatchObject ( { type : { name : 'number' } } )
140
+ } )
142
141
143
- it ( 'should value default example3 props description to be The example3 props ' , ( ) => {
144
- expect ( docButton [ ' props' ] [ ' example3' ] [ 'description' ] ) . toEqual ( 'The example3 props' )
145
- } )
142
+ it ( 'should value default example3 to be 16 ' , ( ) => {
143
+ expect ( props . example3 . defaultValue ) . toMatchObject ( { value : '16' } )
144
+ } )
146
145
147
- it ( 'should onCustomClick to be ignored' , ( ) => {
148
- expect ( docButton [ 'props' ] [ 'onCustomClick' ] [ 'tags' ] [ 'ignore' ] ) . toBeDefined ( )
149
- } )
146
+ it ( 'should value default example3 props description to be The example3 props' , ( ) => {
147
+ expect ( props . example3 . description ) . toEqual ( 'The example3 props' )
148
+ } )
149
+
150
+ it ( 'should onCustomClick to be ignored' , ( ) => {
151
+ expect ( props . onCustomClick . tags . ignore ) . toBeDefined ( )
152
+ } )
150
153
151
- it ( 'should prop1 to be ignored' , ( ) => {
152
- expect ( docButton [ 'props' ] [ 'prop1' ] [ 'tags' ] [ 'ignore' ] ) . toBeDefined ( )
154
+ it ( 'should prop1 to be ignored' , ( ) => {
155
+ expect ( props . prop1 . tags . ignore ) . toBeDefined ( )
156
+ } )
153
157
} )
154
158
155
159
it ( 'should the component has one event' , ( ) => {
156
- expect ( Object . keys ( docButton [ ' events' ] ) . length ) . toEqual ( 1 )
160
+ expect ( Object . keys ( docButton . events ) . length ) . toEqual ( 1 )
157
161
} )
158
162
159
163
it ( 'should the component has event, it called success' , ( ) => {
160
- expect ( docButton [ ' events' ] [ ' success' ] ) . not . toBeUndefined ( )
164
+ expect ( docButton . events . success ) . not . toBeUndefined ( )
161
165
} )
162
166
163
167
it ( 'should the description of success event is Success event.' , ( ) => {
164
- expect ( docButton [ ' events' ] [ ' success' ] [ ' description' ] ) . toEqual ( 'Success event.' )
168
+ expect ( docButton . events . success . description ) . toEqual ( 'Success event.' )
165
169
} )
166
170
167
171
it ( 'should have a slot.' , ( ) => {
168
- expect ( Object . keys ( docButton [ ' slots' ] ) . length ) . toEqual ( 1 )
172
+ expect ( Object . keys ( docButton . slots ) . length ) . toEqual ( 1 )
169
173
} )
170
174
171
175
it ( 'should have a default slot.' , ( ) => {
172
- expect ( typeof docButton [ ' slots' ] [ ' default' ] !== 'undefined' ) . toBe ( true )
176
+ expect ( typeof docButton . slots . default !== 'undefined' ) . toBe ( true )
173
177
} )
174
178
175
179
it ( 'the default slot should have "Use this slot default" as description' , ( ) => {
176
- expect ( docButton [ ' slots' ] [ ' default' ] [ ' description' ] ) . toEqual ( 'Use this slot default' )
180
+ expect ( docButton . slots . default . description ) . toEqual ( 'Use this slot default' )
177
181
} )
178
182
179
183
it ( 'should match the snapshot' , ( ) => {
0 commit comments