Skip to content

Commit

Permalink
chore: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
noootwo committed Nov 29, 2024
1 parent d4469ff commit 9c5b598
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/pinia/test-dts/mapHelpers.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ describe('mapHelpers', () => {
const useSetupStore = defineStore('setupStore', () => {
const a = ref('on' as 'on' | 'off')
const upper = computed(() => a.value.toUpperCase())
const writableUpper = computed({
get: () => a.value.toUpperCase(),
set: (v: 'on' | 'off') => (a.value = v),
})
function toggleA() {
a.value = a.value === 'off' ? 'on' : 'off'
}
function setToggle(aVal: 'on' | 'off') {
return (a.value = aVal)
}
return { a, upper, toggleA, setToggle }
return { a, upper, writableUpper, toggleA, setToggle }
})

const useCounter = defineStore({
Expand Down Expand Up @@ -161,6 +165,17 @@ describe('mapHelpers', () => {
set: (v: 'on' | 'off') => any
}
}>(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']))
})
})
})

0 comments on commit 9c5b598

Please sign in to comment.