Skip to content

Commit 674082b

Browse files
committed
test: add test case
1 parent da91541 commit 674082b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/reactivity/__tests__/reactiveArray.spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { type ComputedRef, computed } from '../src/computed'
22
import { isReactive, reactive, shallowReactive, toRaw } from '../src/reactive'
33
import { isRef, ref } from '../src/ref'
44
import { effect } from '../src/effect'
5+
import { expect } from 'vitest'
56

67
describe('reactivity/reactive/Array', () => {
78
test('should make Array reactive', () => {
@@ -622,5 +623,22 @@ describe('reactivity/reactive/Array', () => {
622623
const firstItem = Array.from(deep.values())[0]
623624
expect(isReactive(firstItem)).toBe(true)
624625
})
626+
627+
test('extend methods', () => {
628+
class Collection extends Array {
629+
find(id: any) {
630+
return super.find(obj => obj.id === id)
631+
}
632+
}
633+
634+
const state = reactive({
635+
things: new Collection(),
636+
})
637+
638+
const val = { id: 'foo', value: 'bar' }
639+
state.things.push(val)
640+
641+
expect(state.things.find('foo')).toBe(val)
642+
})
625643
})
626644
})

0 commit comments

Comments
 (0)