@@ -3,88 +3,91 @@ import { createLocalVue } from '@vue/test-utils'
3
3
import ComponentWithChild from '~resources/components/component-with-child.vue'
4
4
import { describeDoNotRunIf } from 'conditional-specs'
5
5
6
- describeDoNotRunIf ( process . env . TEST_ENV !== 'node' , 'renderToString' , ( ) => {
7
- it ( 'returns a promise' , async ( ) => {
8
- const str = await renderToString ( {
9
- template : `<div>{{this.val}}</div>` ,
10
- data ( ) {
11
- return { val : '123' }
12
- }
6
+ describe ( 'renderToString' , ( ) => {
7
+ it . todo ( 'placeholder' )
8
+ describeDoNotRunIf ( process . env . TEST_ENV !== 'node' , 'renderToString' , ( ) => {
9
+ it ( 'returns a promise' , async ( ) => {
10
+ const str = await renderToString ( {
11
+ template : `<div>{{this.val}}</div>` ,
12
+ data ( ) {
13
+ return { val : '123' }
14
+ }
15
+ } )
16
+ expect ( str ) . toContain ( '123' )
13
17
} )
14
- expect ( str ) . toContain ( '123' )
15
- } )
16
18
17
- it ( 'mounts functional component with a defined context when no context object passed in options' , async ( ) => {
18
- const defaultValue = '[vue-test-utils]: testProp default value'
19
- const Component = {
20
- functional : true ,
21
- props : {
22
- testProp : {
23
- type : String ,
24
- default : defaultValue
25
- }
26
- } ,
27
- render : ( h , { props } ) => h ( 'div' , props . testProp )
28
- }
29
- const str = await renderToString ( Component )
30
- expect ( str ) . toContain ( defaultValue )
31
- } )
19
+ it ( 'mounts functional component with a defined context when no context object passed in options' , async ( ) => {
20
+ const defaultValue = '[vue-test-utils]: testProp default value'
21
+ const Component = {
22
+ functional : true ,
23
+ props : {
24
+ testProp : {
25
+ type : String ,
26
+ default : defaultValue
27
+ }
28
+ } ,
29
+ render : ( h , { props } ) => h ( 'div' , props . testProp )
30
+ }
31
+ const str = await renderToString ( Component )
32
+ expect ( str ) . toContain ( defaultValue )
33
+ } )
32
34
33
- it ( 'mounts component using passed localVue as base Vue' , async ( ) => {
34
- const TestComponent = {
35
- template : `<div>{{test}}</div>`
36
- }
37
- const localVue = createLocalVue ( )
38
- localVue . prototype . test = 'some value'
39
- const str = await renderToString ( TestComponent , {
40
- localVue : localVue
35
+ it ( 'mounts component using passed localVue as base Vue' , async ( ) => {
36
+ const TestComponent = {
37
+ template : `<div>{{test}}</div>`
38
+ }
39
+ const localVue = createLocalVue ( )
40
+ localVue . prototype . test = 'some value'
41
+ const str = await renderToString ( TestComponent , {
42
+ localVue : localVue
43
+ } )
44
+ expect ( str ) . toContain ( 'some value' )
41
45
} )
42
- expect ( str ) . toContain ( 'some value' )
43
- } )
44
46
45
- it ( 'adds variables to vm when passed' , async ( ) => {
46
- const TestComponent = {
47
- template : `
47
+ it ( 'adds variables to vm when passed' , async ( ) => {
48
+ const TestComponent = {
49
+ template : `
48
50
<div>
49
51
{{$store.store}}
50
52
{{$route.path}}
51
53
</div>
52
54
`
53
- }
54
- const $store = { store : true }
55
- const $route = { path : 'http://test.com' }
56
- const str = await renderToString ( TestComponent , {
57
- mocks : {
58
- $store,
59
- $route
60
55
}
61
- } )
62
- expect ( str ) . toContain ( 'true' )
63
- expect ( str ) . toContain ( 'http://test.com' )
64
- } )
65
-
66
- it ( 'mounts component with $parent set to options.parentComponent' , async ( ) => {
67
- const Parent = {
68
- data : ( ) => ( {
69
- customName : 'Parent Name'
56
+ const $store = { store : true }
57
+ const $route = { path : 'http://test.com' }
58
+ const str = await renderToString ( TestComponent , {
59
+ mocks : {
60
+ $store,
61
+ $route
62
+ }
70
63
} )
71
- }
72
- const TestComponent = {
73
- template : '<div>{{$parent.customName}}</div>'
74
- }
75
- const str = await renderToString ( TestComponent , {
76
- parentComponent : Parent
64
+ expect ( str ) . toContain ( 'true' )
65
+ expect ( str ) . toContain ( 'http://test.com' )
77
66
} )
78
- expect ( str ) . toContain ( 'Parent Name' )
79
- } )
80
67
81
- it ( 'replaces component with template string ' , async ( ) => {
82
- const str = await renderToString ( ComponentWithChild , {
83
- stubs : {
84
- ChildComponent : '<div class="stub"></div>'
68
+ it ( 'mounts component with $parent set to options.parentComponent' , async ( ) => {
69
+ const Parent = {
70
+ data : ( ) => ( {
71
+ customName : 'Parent Name'
72
+ } )
73
+ }
74
+ const TestComponent = {
75
+ template : '<div>{{$parent.customName}}</div>'
85
76
}
77
+ const str = await renderToString ( TestComponent , {
78
+ parentComponent : Parent
79
+ } )
80
+ expect ( str ) . toContain ( 'Parent Name' )
86
81
} )
87
82
88
- expect ( str ) . toContain ( '"stub"' )
83
+ it ( 'replaces component with template string ' , async ( ) => {
84
+ const str = await renderToString ( ComponentWithChild , {
85
+ stubs : {
86
+ ChildComponent : '<div class="stub"></div>'
87
+ }
88
+ } )
89
+
90
+ expect ( str ) . toContain ( '"stub"' )
91
+ } )
89
92
} )
90
93
} )
0 commit comments