|
1 |
| -import { mount } from '../src' |
| 1 | +import { mount, shallowMount } from '../src' |
2 | 2 | import WithProps from './components/WithProps.vue'
|
| 3 | +import PropWithSymbol from './components/PropWithSymbol.vue' |
3 | 4 | import Hello from './components/Hello.vue'
|
4 | 5 | import { defineComponent, h } from 'vue'
|
5 | 6 |
|
@@ -224,4 +225,55 @@ describe('props', () => {
|
224 | 225 |
|
225 | 226 | expect(wrapper.text()).toEqual('hello')
|
226 | 227 | })
|
| 228 | + |
| 229 | + describe('edge case with symbol props and stubs', () => { |
| 230 | + it('works with Symbol as default', () => { |
| 231 | + const Comp = defineComponent({ |
| 232 | + template: `<div>Symbol: {{ sym }}</div>`, |
| 233 | + props: { |
| 234 | + sym: { |
| 235 | + type: Symbol, |
| 236 | + default: () => Symbol() |
| 237 | + } |
| 238 | + } |
| 239 | + }) |
| 240 | + |
| 241 | + const wrapper = shallowMount(Comp) |
| 242 | + |
| 243 | + expect(wrapper.html()).toBe('<div>Symbol: Symbol()</div>') |
| 244 | + }) |
| 245 | + |
| 246 | + it('works with symbol as array syntax', () => { |
| 247 | + const Comp = defineComponent({ |
| 248 | + name: 'Comp', |
| 249 | + template: `<div>Symbol: {{ sym }}</div>`, |
| 250 | + props: ['sym'] |
| 251 | + }) |
| 252 | + |
| 253 | + const wrapper = shallowMount({ |
| 254 | + render() { |
| 255 | + return h(Comp, { sym: Symbol() }) |
| 256 | + } |
| 257 | + }) |
| 258 | + |
| 259 | + expect(wrapper.html()).toBe('<comp-stub sym="Symbol()"></comp-stub>') |
| 260 | + }) |
| 261 | + |
| 262 | + it('works with symbol as default from SFC', () => { |
| 263 | + const App = defineComponent({ |
| 264 | + template: `<PropWithSymbol :sym="sym" />`, |
| 265 | + components: { PropWithSymbol }, |
| 266 | + data() { |
| 267 | + return { |
| 268 | + sym: Symbol() |
| 269 | + } |
| 270 | + } |
| 271 | + }) |
| 272 | + const wrapper = shallowMount(App) |
| 273 | + |
| 274 | + expect(wrapper.html()).toBe( |
| 275 | + '<prop-with-symbol-stub sym="Symbol()"></prop-with-symbol-stub>' |
| 276 | + ) |
| 277 | + }) |
| 278 | + }) |
227 | 279 | })
|
0 commit comments