File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,12 @@ export class VueWrapper<T extends ComponentPublicInstance>
46
46
return this . componentVM
47
47
}
48
48
49
+ props ( selector ?: string ) {
50
+ return selector
51
+ ? this . componentVM . $props [ selector ]
52
+ : this . componentVM . $props
53
+ }
54
+
49
55
classes ( className ?: string ) {
50
56
return new DOMWrapper ( this . element ) . classes ( className )
51
57
}
Original file line number Diff line number Diff line change
1
+ import { mount } from '../src'
2
+ import WithProps from './components/WithProps.vue'
3
+ import Hello from './components/Hello.vue'
4
+
5
+ describe ( 'props' , ( ) => {
6
+ it ( 'returns a single prop applied to a component' , ( ) => {
7
+ const wrapper = mount ( WithProps , { props : { msg : 'ABC' } } )
8
+ expect ( wrapper . props ( 'msg' ) ) . toEqual ( 'ABC' )
9
+ } )
10
+
11
+ it ( 'returns all props applied to a component' , ( ) => {
12
+ const wrapper = mount ( WithProps , { props : { msg : 'ABC' } } )
13
+ expect ( wrapper . props ( ) ) . toEqual ( { msg : 'ABC' } )
14
+ } )
15
+
16
+ it ( 'returns undefined if props does not exist' , ( ) => {
17
+ const wrapper = mount ( WithProps , { props : { msg : 'ABC' } } )
18
+ expect ( wrapper . props ( 'foo' ) ) . toEqual ( undefined )
19
+ } )
20
+
21
+ it ( 'returns empty object for components without props' , ( ) => {
22
+ const wrapper = mount ( Hello )
23
+ expect ( wrapper . props ( ) ) . toEqual ( { } )
24
+ } )
25
+ } )
You can’t perform that action at this time.
0 commit comments