Skip to content

Commit

Permalink
docs(useArrayUnique): fix demo (#2609)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfred-Skyblue committed Jan 9, 2023
1 parent db4aacc commit 6cbf4a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/shared/useArrayUnique/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ const list = reactive([1, 2, 2, 3])
const result = useArrayUnique(list)
// result.value: [1, 2, 3]

result.value.push(1)
list.push(1)
// result.value: [1, 2, 3]
```
12 changes: 10 additions & 2 deletions packages/shared/useArrayUnique/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ref } from 'vue-demi'
import { reactive, ref } from 'vue-demi'
import { useArrayUnique } from '../useArrayUnique'

describe('useArraySome', () => {
Expand All @@ -19,11 +19,19 @@ describe('useArraySome', () => {
expect(result.value.length).toBe(3)
})

it('should work with reactive array', () => {
it('should work with ref array', () => {
const list = ref([1, 2, 2, 3])
const result = useArrayUnique(list)
expect(result.value.length).toBe(3)
list.value.push(1)
expect(result.value.length).toBe(3)
})

it('should work with reactive array', () => {
const list = reactive([1, 2, 2, 3])
const result = useArrayUnique(list)
expect(result.value.length).toBe(3)
list.push(1)
expect(result.value.length).toBe(3)
})
})

0 comments on commit 6cbf4a0

Please sign in to comment.