chore: improve typings in reactivity tests (#96)
This commit is contained in:
committed by
Evan You
parent
0fe8801782
commit
600ec5de42
@@ -2,7 +2,7 @@ import { computed, reactive, effect, stop, ref } from '../src'
|
||||
|
||||
describe('reactivity/computed', () => {
|
||||
it('should return updated value', () => {
|
||||
const value: any = reactive({})
|
||||
const value = reactive<{ foo?: number }>({})
|
||||
const cValue = computed(() => value.foo)
|
||||
expect(cValue.value).toBe(undefined)
|
||||
value.foo = 1
|
||||
@@ -10,7 +10,7 @@ describe('reactivity/computed', () => {
|
||||
})
|
||||
|
||||
it('should compute lazily', () => {
|
||||
const value: any = reactive({})
|
||||
const value = reactive<{ foo?: number }>({})
|
||||
const getter = jest.fn(() => value.foo)
|
||||
const cValue = computed(getter)
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('reactivity/computed', () => {
|
||||
})
|
||||
|
||||
it('should trigger effect', () => {
|
||||
const value: any = reactive({})
|
||||
const value = reactive<{ foo?: number }>({})
|
||||
const cValue = computed(() => value.foo)
|
||||
let dummy
|
||||
effect(() => {
|
||||
@@ -50,7 +50,7 @@ describe('reactivity/computed', () => {
|
||||
})
|
||||
|
||||
it('should work when chained', () => {
|
||||
const value: any = reactive({ foo: 0 })
|
||||
const value = reactive({ foo: 0 })
|
||||
const c1 = computed(() => value.foo)
|
||||
const c2 = computed(() => c1.value + 1)
|
||||
expect(c2.value).toBe(1)
|
||||
@@ -61,7 +61,7 @@ describe('reactivity/computed', () => {
|
||||
})
|
||||
|
||||
it('should trigger effect when chained', () => {
|
||||
const value: any = reactive({ foo: 0 })
|
||||
const value = reactive({ foo: 0 })
|
||||
const getter1 = jest.fn(() => value.foo)
|
||||
const getter2 = jest.fn(() => {
|
||||
return c1.value + 1
|
||||
@@ -84,7 +84,7 @@ describe('reactivity/computed', () => {
|
||||
})
|
||||
|
||||
it('should trigger effect when chained (mixed invocations)', () => {
|
||||
const value: any = reactive({ foo: 0 })
|
||||
const value = reactive({ foo: 0 })
|
||||
const getter1 = jest.fn(() => value.foo)
|
||||
const getter2 = jest.fn(() => {
|
||||
return c1.value + 1
|
||||
@@ -108,7 +108,7 @@ describe('reactivity/computed', () => {
|
||||
})
|
||||
|
||||
it('should no longer update when stopped', () => {
|
||||
const value: any = reactive({})
|
||||
const value = reactive<{ foo?: number }>({})
|
||||
const cValue = computed(() => value.foo)
|
||||
let dummy
|
||||
effect(() => {
|
||||
|
||||
Reference in New Issue
Block a user