Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reactivePick): add test cases (#2653)
* feat(reactivePick): add test cases * fix(reactivePick): eslint Co-authored-by: 丶远方 <pantengyang@cybstar.com> Co-authored-by: wheat <jacobrclevenger@gmail.com>
- Loading branch information
1 parent
07c9517
commit b06b84e
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
}) | ||
}) | ||
}) |