File tree 12 files changed +1660
-21
lines changed
data-display/CopyField/__snapshots__
12 files changed +1660
-21
lines changed Original file line number Diff line number Diff line change 1
- module . exports = {
2
- presets : [ '@vue/app' ] ,
3
- plugins : [ "@babel/plugin-syntax-dynamic-import" ]
1
+ module . exports = function ( api ) {
2
+ const config = {
3
+ presets : [ '@vue/app' ] ,
4
+ plugins : [ '@babel/plugin-syntax-dynamic-import' ]
5
+ }
6
+ if ( api . env ( 'test' ) ) {
7
+ // mocks require.context() in test environment
8
+ config . plugins . push ( 'transform-require-context' )
9
+ }
10
+ return config
4
11
}
Original file line number Diff line number Diff line change 28
28
"async-validator" : " ^1.8.5" ,
29
29
"babel-core" : " 7.0.0-bridge.0" ,
30
30
"babel-jest" : " ^23.0.1" ,
31
+ "babel-plugin-transform-require-context" : " ^0.0.3" ,
31
32
"cheerio" : " ^1.0.0-rc.2" ,
32
33
"clipboard-copy" : " ^2.0.1" ,
33
34
"clone-deep" : " ^4.0.0" ,
Original file line number Diff line number Diff line change @@ -11,10 +11,11 @@ exports[`CopyField.vue matches snapshot 1`] = `
11
11
<div
12
12
class = " ds-copy-field-link"
13
13
>
14
- <ds-button
14
+ <dsbutton-stub
15
15
color = " soft"
16
- ghost = " "
16
+ ghost = " true "
17
17
icon = " copy"
18
+ linktag = " button"
18
19
/>
19
20
</div >
20
21
Original file line number Diff line number Diff line change 2
2
<ds-form-item >
3
3
<div
4
4
class =" ds-select-wrap"
5
- v-click-outside =" handleBlur" >
5
+ v-click-outside =" handleBlur"
6
+ @keyup.esc =" close" >
6
7
<div
7
8
v-if =" icon"
8
9
class =" ds-select-icon" >
30
31
</slot >
31
32
</div >
32
33
<input
34
+ ref =" search"
33
35
class =" ds-select-search"
34
36
:id =" id"
35
37
:name =" model"
38
40
:disabled =" disabled"
39
41
:readonly =" readonly"
40
42
v-model =" searchString"
41
- @focus =" handleFocus" >
43
+ @focus =" handleFocus"
44
+ @keyup.esc =" close" >
42
45
</div >
43
46
<div class =" ds-select-dropdown" >
44
47
<ul class =" ds-select-options" >
71
74
<script >
72
75
import inputMixin from ' ../shared/input'
73
76
import ClickOutside from ' vue-click-outside'
77
+ import DsFormItem from ' @@/components/data-input/FormItem/FormItem'
78
+ import DsIcon from ' @@/components/typography/Icon/Icon'
74
79
75
80
/**
76
81
* Used for handling basic user input.
@@ -79,6 +84,10 @@ import ClickOutside from 'vue-click-outside'
79
84
export default {
80
85
name: ' DsSelect' ,
81
86
mixins: [inputMixin],
87
+ components: {
88
+ DsFormItem,
89
+ DsIcon
90
+ },
82
91
directives: {
83
92
ClickOutside
84
93
},
@@ -173,6 +182,10 @@ export default {
173
182
},
174
183
resetSearch () {
175
184
this .searchString = ' '
185
+ },
186
+ close () {
187
+ this .$refs .search .blur ()
188
+ this .handleBlur ()
176
189
}
177
190
}
178
191
}
Original file line number Diff line number Diff line change
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports [` Select.vue matches snapshot 1` ] = `
4
+ <dsformitem-stub >
5
+ <div
6
+ class = " ds-select-wrap"
7
+ >
8
+ <!---->
9
+
10
+ <div
11
+ class = " ds-select ds-select-has-icon-right"
12
+ >
13
+ <div
14
+ class = " ds-select-value"
15
+ >
16
+
17
+ 1
18
+
19
+ </div >
20
+
21
+ <input
22
+ class = " ds-select-search"
23
+ />
24
+ </div >
25
+
26
+ <div
27
+ class = " ds-select-dropdown"
28
+ >
29
+ <ul
30
+ class = " ds-select-options"
31
+ >
32
+ <li
33
+ class = " ds-select-option ds-select-option-is-selected"
34
+ >
35
+
36
+ 1
37
+
38
+ </li >
39
+ <li
40
+ class = " ds-select-option"
41
+ >
42
+
43
+ 2
44
+
45
+ </li >
46
+ <li
47
+ class = " ds-select-option"
48
+ >
49
+
50
+ 3
51
+
52
+ </li >
53
+ </ul >
54
+ </div >
55
+
56
+ <div
57
+ class = " ds-select-icon-right"
58
+ >
59
+ <dsicon-stub
60
+ arialabel = " icon"
61
+ name = " angle-down"
62
+ tag = " span"
63
+ />
64
+ </div >
65
+ </div >
66
+ </dsformitem-stub >
67
+ ` ;
Original file line number Diff line number Diff line change
1
+ import { shallowMount } from '@vue/test-utils'
2
+ import Comp from './Select.vue'
3
+
4
+ describe ( 'Select.vue' , ( ) => {
5
+ let wrapper
6
+
7
+ describe ( 'Events emitting' , ( ) => {
8
+ describe ( '@input' , ( ) => {
9
+ test ( 'should be called when the value is changed passing the new value' , ( ) => {
10
+ const wrapper = shallowMount ( Comp , {
11
+ propsData : {
12
+ value : '3' ,
13
+ options : [ '1' , '2' , '3' ]
14
+ }
15
+ } )
16
+ wrapper . vm . selectOption ( wrapper . vm . options [ 0 ] )
17
+ expect ( wrapper . emitted ( ) . input [ 0 ] ) . toEqual ( [ '1' ] )
18
+ } )
19
+ test ( 'should be called when the an option is clicked passing the options value' , ( ) => {
20
+ const wrapper = shallowMount ( Comp , {
21
+ propsData : {
22
+ value : '3' ,
23
+ options : [ '1' , '2' , '3' ]
24
+ }
25
+ } )
26
+ wrapper . find ( '.ds-select-option' ) . trigger ( 'click' )
27
+ expect ( wrapper . emitted ( ) . input [ 0 ] ) . toEqual ( [ '1' ] )
28
+ } )
29
+ } )
30
+ } )
31
+
32
+ it ( 'matches snapshot' , ( ) => {
33
+ const wrapper = shallowMount ( Comp , {
34
+ propsData : {
35
+ value : '1' ,
36
+ options : [ '1' , '2' , '3' ]
37
+ }
38
+ } )
39
+ expect ( wrapper . element ) . toMatchSnapshot ( )
40
+ } )
41
+ } )
Original file line number Diff line number Diff line change 10
10
}
11
11
12
12
.ds-select-search , .ds-select-placeholder , .ds-select-value {
13
+ box-sizing : border-box ;
13
14
position : absolute ;
14
15
top : 0 ;
15
16
left : 0 ;
16
17
right : 0 ;
17
18
bottom : 0 ;
18
19
border : $input-border-size solid transparent ;
19
20
padding : $input-padding-vertical $space-x-small ;
21
+ line-height : $line-height-base ;
20
22
21
23
.ds-input-size-small & {
22
24
padding : $input-padding-vertical-small $space-x-small ;
26
28
padding : $input-padding-vertical-large $space-x-small ;
27
29
}
28
30
29
- .ds-select-has-icon + & {
31
+ .ds-select-has-icon & {
30
32
padding-left : $input-height ;
31
33
32
34
.ds-input-size-small & {
38
40
}
39
41
}
40
42
41
- .ds-select-has-icon-right + & {
43
+ .ds-select-has-icon-right & {
42
44
padding-right : $input-height ;
43
45
44
46
.ds-input-size-small & {
53
55
54
56
.ds-select-search {
55
57
appearance : none ;
56
- box-sizing : border-box ;
57
- font-size : $font-size-base ;
58
- line-height : $line-height-base ;
58
+ font-size : inherit ;
59
59
font-family : $font-family-text ;
60
60
width : 100% ;
61
- height : $input-height ;
62
61
background : transparent ;
63
62
color : $text-color-base ;
64
63
outline : none ;
Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ export default {
111
111
this . input ( event . target . value )
112
112
} ,
113
113
input ( value ) {
114
+ this . innerValue = value
114
115
if ( this . $parentForm ) {
115
116
this . $parentForm . update ( this . model , value )
116
117
} else {
Original file line number Diff line number Diff line change 6
6
.#{$class } {
7
7
appearance : none ;
8
8
box-sizing : border-box ;
9
- font-size : $font-size-base ;
9
+ font-size : $input- font-size-base ;
10
10
line-height : $line-height-base ;
11
11
font-family : $font-family-text ;
12
12
width : 100% ;
47
47
font-size : $font-size-small ;
48
48
49
49
.#{$class } {
50
+ font-size : $input-font-size-small ;
50
51
height : $input-height-small ;
51
52
padding : $input-padding-vertical-small $space-x-small ;
52
53
}
56
57
font-size : $font-size-large ;
57
58
58
59
.#{$class } {
60
+ font-size : $input-font-size-large ;
59
61
height : $input-height-large ;
60
62
padding : $input-padding-vertical-large $space-x-small ;
61
63
}
Original file line number Diff line number Diff line change 19
19
align-items : center ;
20
20
justify-content : center ;
21
21
text-decoration : none ;
22
- padding : $input-padding-vertical $space-small ;
22
+ padding : 0 $space-small ;
23
23
height : $input-height ;
24
24
border-radius : $border-radius-base ;
25
25
box-shadow : $box-shadow-small-inset , $box-shadow-x-small ;
160
160
161
161
.ds-button-size-small {
162
162
font-size : $font-size-small ;
163
- padding : $input-padding-vertical-small $space-x-small ;
163
+ padding : 0 $space-x-small ;
164
164
height : $input-height-small ;
165
165
}
166
166
167
167
.ds-button-size-large {
168
168
font-size : $font-size-large ;
169
- padding : $input-padding-vertical-large $space-base ;
169
+ padding : 0 $space-base ;
170
170
height : $input-height-large ;
171
171
}
172
172
Original file line number Diff line number Diff line change 1
1
/* FORM VARIABLES / MIXINS
2
2
--------------------------------------------- */
3
3
4
+ $input-font-size-base : $font-size-base ;
4
5
$input-border-size : $border-size-base ;
5
6
$input-padding-vertical : $space-x-small ;
6
7
$input-height : calc (
7
8
#{$font-size-base * $line-height-base } + #{($input-padding-vertical + $input-border-size ) * 2 }
8
9
);
9
10
10
- $input-padding-vertical-small : $space-xx-small ;
11
+ $input-font-size-small : $font-size-base ;
12
+ $input-padding-vertical-small : $space-xxx-small ;
11
13
$input-height-small : calc (
12
- #{$font-size-small * $line-height-base } + #{($input-padding-vertical-small + $input-border-size ) * 2 }
14
+ #{$font-size-base * $line-height-base } + #{($input-padding-vertical-small + $input-border-size ) * 2 }
13
15
);
14
16
17
+ $input-font-size-large : $font-size-large ;
15
18
$input-padding-vertical-large : $space-x-small ;
16
19
$input-height-large : calc (
17
- #{$font-size-large * $line-height-base } + #{($input-padding-vertical-large + $input-border-size ) * 2 }
20
+ #{$input- font-size-large * $line-height-base } + #{($input-padding-vertical-large + $input-border-size ) * 2 }
18
21
);
You can’t perform that action at this time.
0 commit comments