I'm currently utilising vueuse/core's onKeyStroke event sensor.
onKeyStroke(
'c',
(e) => {
e.preventDefault()
showAsterisms.value = false
showConstellations.value = !showConstellations.value
},
{
target: document
}
)
I'm looking to test this functionality with the following:
it('Constellations Should Be Visible', async () => {
wrapper.trigger('keydown', {
key: 'c'
})
await wrapper.vm.$nextTick()
const canvas = wrapper.find('canvas')
const canvasAttributes = canvas.attributes()
expect(canvasAttributes['data-constellations']).toBe('true')
})
Where the wrapper is a mounted component:
const wrapper = mount(MyComponent, {
props: {
...
}
})
I then have the following bound property on the canvas:
<canvas :data-constellations="showConstellations" />
However, with this setup, it seems that this particular setup the data-constellations attribute on the canvas elmenent is always set to the default false, and after the keyPress it is not updated ...
Could someone advise me please on what I need to do to get this working?