]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test(reactivity): adjust ref unwrap test inside arrays (#1457)
authorPick <pickchen@tencent.com>
Mon, 29 Jun 2020 16:10:29 +0000 (00:10 +0800)
committerGitHub <noreply@github.com>
Mon, 29 Jun 2020 16:10:29 +0000 (12:10 -0400)
packages/reactivity/__tests__/ref.spec.ts

index 952960ac2f65d48627260f53f2ab89a15e42d003..6bfcceaef541b5a8fb21d465bff43fcd8910d364 100644 (file)
@@ -109,21 +109,10 @@ describe('reactivity/ref', () => {
   })
 
   it('should NOT unwrap ref types nested inside arrays', () => {
-    const arr = ref([1, ref(1)]).value
-    ;(arr[0] as number)++
-    ;(arr[1] as Ref<number>).value++
-
-    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')
-    }
+    const arr = ref([1, ref(3)]).value
+    expect(isRef(arr[0])).toBe(false)
+    expect(isRef(arr[1])).toBe(true)
+    expect((arr[1] as Ref).value).toBe(3)
   })
 
   it('should keep tuple types', () => {