Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nbonamy committed Apr 27, 2024
1 parent bb1b701 commit 65ffb0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/components/Prompt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ const onKeyDown = (event) => {
nextTick(() => {
autoGrow(input.value)
input.value.setSelectionRange(newPrompt.length, newPrompt.length)
input.value.scrollTo(0, input.value.scrollHeight)
if (input.value.scrollTo) {
// no scrollTo while testing
input.value.scrollTo(0, input.value.scrollHeight)
}
})
event.preventDefault()
event.stopPropagation()
Expand Down
14 changes: 7 additions & 7 deletions tests/components/prompt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,17 @@ test('History navigation', async () => {
]})})

const prompt = wrapper.find('.input textarea')
await prompt.setValue('')
await prompt.trigger('keyup.ArrowUp')
await prompt.setValue('Hola')
await prompt.trigger('keydown.ArrowUp', { shiftKey: true })
expect(prompt.element.value).toBe('Bonjour')
await prompt.trigger('keyup.ArrowUp')
await prompt.trigger('keydown.ArrowUp', { shiftKey: true })
expect(prompt.element.value).toBe('Hello')
await prompt.trigger('keyup.ArrowUp')
await prompt.trigger('keydown.ArrowUp', { shiftKey: true })
expect(prompt.element.value).toBe('Hello')
await prompt.trigger('keyup.ArrowDown')
await prompt.trigger('keydown.ArrowDown', { shiftKey: true })
expect(prompt.element.value).toBe('Bonjour')
await prompt.trigger('keyup.ArrowDown')
expect(prompt.element.value).toBe('')
await prompt.trigger('keydown.ArrowDown', { shiftKey: true })
expect(prompt.element.value).toBe('Hola')

})

Expand Down

0 comments on commit 65ffb0e

Please sign in to comment.