|
1 | 1 | import { describe, expect, it, vi } from 'vitest' |
2 | | -import { defineComponent } from 'vue' |
| 2 | +import { defineComponent, ref } from 'vue' |
3 | 3 | import { mount } from '../src' |
4 | 4 | import DefinePropsAndDefineEmits from './components/DefinePropsAndDefineEmits.vue' |
| 5 | +import WithDeepRef from './components/WithDeepRef.vue' |
5 | 6 | import HelloFromVitestPlayground from './components/HelloFromVitestPlayground.vue' |
6 | 7 |
|
7 | 8 | describe('mount: general tests', () => { |
@@ -44,4 +45,37 @@ describe('mount: general tests', () => { |
44 | 45 | expect(wrapper.get('div').text()).toContain('Hello') |
45 | 46 | expect(wrapper.get('div').classes()).toContain('end') |
46 | 47 | }) |
| 48 | + it('allows access to nested computed values', async () => { |
| 49 | + const wrapper = mount(WithDeepRef, { |
| 50 | + props: { |
| 51 | + count: ref(1), |
| 52 | + oneLayerCountObject: { count: ref(2) }, |
| 53 | + twoLayersCountObject: { oneLayerCountObject: { count: ref(3) } }, |
| 54 | + |
| 55 | + countArray: [ref(4)], |
| 56 | + countMatrix: [[ref(5)]], |
| 57 | + |
| 58 | + oneLayerCountObjectArray: [{ count: ref(6) }], |
| 59 | + oneLayerCountArrayObject: { count: [ref(7)] }, |
| 60 | + oneLayerCountObjectMatrix: [[{ count: ref(8) }]] |
| 61 | + } |
| 62 | + }) |
| 63 | + |
| 64 | + expect(wrapper.get('#countValue').text()).toBe('1') |
| 65 | + expect(wrapper.vm.countValue).toBe(1) |
| 66 | + expect(wrapper.get('#oneLayerCountObjectValue').text()).toBe('2') |
| 67 | + expect(wrapper.vm.oneLayerCountObjectValue).toBe(2) |
| 68 | + expect(wrapper.get('#twoLayersCountObjectValue').text()).toBe('3') |
| 69 | + expect(wrapper.vm.twoLayersCountObjectValue).toBe(3) |
| 70 | + expect(wrapper.get('#countArrayValue').text()).toBe('4') |
| 71 | + expect(wrapper.vm.countArrayValue).toBe(4) |
| 72 | + expect(wrapper.get('#countMatrixValue').text()).toBe('5') |
| 73 | + expect(wrapper.vm.countMatrixValue).toBe(5) |
| 74 | + expect(wrapper.get('#oneLayerCountObjectArrayValue').text()).toBe('6') |
| 75 | + expect(wrapper.vm.oneLayerCountObjectArrayValue).toBe(6) |
| 76 | + expect(wrapper.get('#oneLayerCountArrayObjectValue').text()).toBe('7') |
| 77 | + expect(wrapper.vm.oneLayerCountArrayObjectValue).toBe(7) |
| 78 | + expect(wrapper.get('#oneLayerCountObjectMatrixValue').text()).toBe('8') |
| 79 | + expect(wrapper.vm.oneLayerCountObjectMatrixValue).toBe(8) |
| 80 | + }) |
47 | 81 | }) |
0 commit comments