Skip to content

Commit

Permalink
feat(reactivePick): add test cases (#2653)
Browse files Browse the repository at this point in the history
* feat(reactivePick): add test cases

* fix(reactivePick):  eslint

Co-authored-by: 丶远方 <pantengyang@cybstar.com>
Co-authored-by: wheat <jacobrclevenger@gmail.com>
  • Loading branch information
3 people committed Jan 17, 2023
1 parent 07c9517 commit b06b84e
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions packages/shared/reactivePick/index.test.ts
@@ -0,0 +1,47 @@
import { reactive } from 'vue-demi'
import { reactivePick } from '../reactivePick'

describe('reactivePick', () => {
it('should be defined', () => {
expect(reactivePick).toBeDefined()
})

it('should work', () => {
const source = reactive({
foo: 'foo',
bar: 'bar',
})
const state = reactivePick(source, 'bar')

expect(state).toEqual({
bar: 'bar',
})

source.foo = 'foo2'

expect(state).toEqual({
bar: 'bar',
})

source.bar = 'bar1'

expect(state).toEqual({
bar: 'bar1',
})
})

it('should write back', () => {
const source = reactive({
foo: 'foo',
bar: 'bar',
})
const state = reactivePick(source, 'bar')

state.bar = 'bar2'

expect(source).toEqual({
foo: 'foo',
bar: 'bar2',
})
})
})

0 comments on commit b06b84e

Please sign in to comment.