test(reactivity): adjust ref unwrap test inside arrays (#1457)

This commit is contained in:
Pick 2020-06-30 00:10:29 +08:00 committed by GitHub
parent d4cd12887e
commit 028a8c20df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -109,21 +109,10 @@ describe('reactivity/ref', () => {
}) })
it('should NOT unwrap ref types nested inside arrays', () => { it('should NOT unwrap ref types nested inside arrays', () => {
const arr = ref([1, ref(1)]).value const arr = ref([1, ref(3)]).value
;(arr[0] as number)++ expect(isRef(arr[0])).toBe(false)
;(arr[1] as Ref<number>).value++ expect(isRef(arr[1])).toBe(true)
expect((arr[1] as Ref).value).toBe(3)
const arr2 = ref([1, new Map<string, any>(), ref('1')]).value
const value = arr2[0]
if (isRef(value)) {
value + 'foo'
} else if (typeof value === 'number') {
value + 1
} else {
// should narrow down to Map type
// and not contain any Ref type
value.has('foo')
}
}) })
it('should keep tuple types', () => { it('should keep tuple types', () => {