test(reactivity): extracted repetitive assertions (#554)

This commit is contained in:
Elad Frizi 2019-12-30 18:29:43 +02:00 committed by Evan You
parent 5ec05f09ca
commit 1cf1ad5e94

View File

@ -42,33 +42,29 @@ describe('reactivity/ref', () => {
d: [a]
}
})
let dummy1
let dummy2
let dummy3
let dummy1: number
let dummy2: number
let dummy3: number
effect(() => {
dummy1 = obj.a
dummy2 = obj.b.c
dummy3 = obj.b.d[0]
})
expect(dummy1).toBe(1)
expect(dummy2).toBe(1)
expect(dummy3).toBe(1)
const assertDummiesEqualTo = (val: any) =>
[dummy1, dummy2, dummy3].forEach(dummy => expect(dummy).toBe(val))
assertDummiesEqualTo(1)
a.value++
expect(dummy1).toBe(2)
expect(dummy2).toBe(2)
expect(dummy3).toBe(2)
assertDummiesEqualTo(2)
obj.a++
expect(dummy1).toBe(3)
expect(dummy2).toBe(3)
expect(dummy3).toBe(3)
assertDummiesEqualTo(3)
obj.b.c++
expect(dummy1).toBe(4)
expect(dummy2).toBe(4)
expect(dummy3).toBe(4)
assertDummiesEqualTo(4)
obj.b.d[0]++
expect(dummy1).toBe(5)
expect(dummy2).toBe(5)
expect(dummy3).toBe(5)
assertDummiesEqualTo(5)
})
it('should unwrap nested ref in types', () => {