test(reactivity): extracted repetitive assertions (#554)
This commit is contained in:
parent
5ec05f09ca
commit
1cf1ad5e94
@ -42,33 +42,29 @@ describe('reactivity/ref', () => {
|
|||||||
d: [a]
|
d: [a]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let dummy1
|
|
||||||
let dummy2
|
let dummy1: number
|
||||||
let dummy3
|
let dummy2: number
|
||||||
|
let dummy3: number
|
||||||
|
|
||||||
effect(() => {
|
effect(() => {
|
||||||
dummy1 = obj.a
|
dummy1 = obj.a
|
||||||
dummy2 = obj.b.c
|
dummy2 = obj.b.c
|
||||||
dummy3 = obj.b.d[0]
|
dummy3 = obj.b.d[0]
|
||||||
})
|
})
|
||||||
expect(dummy1).toBe(1)
|
|
||||||
expect(dummy2).toBe(1)
|
const assertDummiesEqualTo = (val: any) =>
|
||||||
expect(dummy3).toBe(1)
|
[dummy1, dummy2, dummy3].forEach(dummy => expect(dummy).toBe(val))
|
||||||
|
|
||||||
|
assertDummiesEqualTo(1)
|
||||||
a.value++
|
a.value++
|
||||||
expect(dummy1).toBe(2)
|
assertDummiesEqualTo(2)
|
||||||
expect(dummy2).toBe(2)
|
|
||||||
expect(dummy3).toBe(2)
|
|
||||||
obj.a++
|
obj.a++
|
||||||
expect(dummy1).toBe(3)
|
assertDummiesEqualTo(3)
|
||||||
expect(dummy2).toBe(3)
|
|
||||||
expect(dummy3).toBe(3)
|
|
||||||
obj.b.c++
|
obj.b.c++
|
||||||
expect(dummy1).toBe(4)
|
assertDummiesEqualTo(4)
|
||||||
expect(dummy2).toBe(4)
|
|
||||||
expect(dummy3).toBe(4)
|
|
||||||
obj.b.d[0]++
|
obj.b.d[0]++
|
||||||
expect(dummy1).toBe(5)
|
assertDummiesEqualTo(5)
|
||||||
expect(dummy2).toBe(5)
|
|
||||||
expect(dummy3).toBe(5)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should unwrap nested ref in types', () => {
|
it('should unwrap nested ref in types', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user