|
4 | 4 | isRunningPhantomJS
|
5 | 5 | } from '~resources/utils'
|
6 | 6 | import ComponentWithScopedSlots from '~resources/components/component-with-scoped-slots.vue'
|
7 |
| -import { itDoNotRunIf } from 'conditional-specs' |
| 7 | +import { itSkipIf, itDoNotRunIf } from 'conditional-specs' |
8 | 8 |
|
9 | 9 | describeWithShallowAndMount('scopedSlots', mountingMethod => {
|
10 | 10 | const windowSave = window
|
@@ -165,4 +165,43 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => {
|
165 | 165 | .with.property('message', message)
|
166 | 166 | }
|
167 | 167 | )
|
| 168 | + |
| 169 | + itSkipIf( |
| 170 | + mountingMethod.name === 'renderToString', |
| 171 | + 'throws error if passed string in default slot object and vue-template-compiler is undefined', |
| 172 | + () => { |
| 173 | + const compilerSave = |
| 174 | + require.cache[require.resolve('vue-template-compiler')].exports |
| 175 | + .compileToFunctions |
| 176 | + require.cache[ |
| 177 | + require.resolve('vue-template-compiler') |
| 178 | + ].exports.compileToFunctions = undefined |
| 179 | + delete require.cache[require.resolve('../../../packages/test-utils')] |
| 180 | + const mountingMethodFresh = require('../../../packages/test-utils')[ |
| 181 | + mountingMethod.name |
| 182 | + ] |
| 183 | + const message = |
| 184 | + '[vue-test-utils]: vueTemplateCompiler is undefined, you must pass precompiled components if vue-template-compiler is undefined' |
| 185 | + const fn = () => { |
| 186 | + mountingMethodFresh(ComponentWithScopedSlots, { |
| 187 | + scopedSlots: { |
| 188 | + list: '<p slot-scope="foo">{{foo.index}},{{foo.text}}</p>' |
| 189 | + } |
| 190 | + }) |
| 191 | + } |
| 192 | + try { |
| 193 | + expect(fn) |
| 194 | + .to.throw() |
| 195 | + .with.property('message', message) |
| 196 | + } catch (err) { |
| 197 | + require.cache[ |
| 198 | + require.resolve('vue-template-compiler') |
| 199 | + ].exports.compileToFunctions = compilerSave |
| 200 | + throw err |
| 201 | + } |
| 202 | + require.cache[ |
| 203 | + require.resolve('vue-template-compiler') |
| 204 | + ].exports.compileToFunctions = compilerSave |
| 205 | + } |
| 206 | + ) |
168 | 207 | })
|
0 commit comments