Skip to content

Commit

Permalink
chore: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
noootwo committed Nov 29, 2024
1 parent 9c5b598 commit b953287
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
25 changes: 9 additions & 16 deletions packages/pinia/__tests__/mapHelpers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,30 +248,23 @@ describe('Map Helpers', () => {

it('setup store', async () => {
const useSetupStore = defineStore('setup', () => {
const a = ref(true)
const n = ref(0)
const text = ref('initial')

const double = computed({
get: () => n.value + n.value,
const textUpper = computed({
get: () => text.value.toUpperCase(),
set: (v) => {
n.value = v
},
})
const notA = computed({
get: () => !a.value,
set: (v) => {
a.value = v
text.value = v
},
})

return { a, n, double, notA }
return { text, textUpper }
})

await testComponent(
mapWritableState(useSetupStore, ['n', 'a', 'double', 'notA']),
`{{ n }} {{ a }} {{ double }} {{ notA }}`,
`0 true 0 false`,
'replaced replaced replacedreplaced false'
mapWritableState(useSetupStore, ['text', 'textUpper']),
`{{ text }} {{ textUpper }}`,
`initial INITIAL`,
'replaced REPLACED'
)
})
})
Expand Down
6 changes: 1 addition & 5 deletions packages/pinia/test-dts/mapHelpers.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,11 @@ describe('mapHelpers', () => {
}>(mapWritableState(useSetupStore, ['a']))

expectTypeOf<{
a: {
get: () => 'on' | 'off'
set: (v: 'on' | 'off') => any
}
writableUpper: {
get: () => string
set: (v: 'on' | 'off') => any
}
}>(mapWritableState(useSetupStore, ['a', 'writableUpper']))
}>(mapWritableState(useSetupStore, ['writableUpper']))
})
})
})

0 comments on commit b953287

Please sign in to comment.