From e55fb185092f9a6e246f0a21cb6498fcfb1b6675 Mon Sep 17 00:00:00 2001 From: Conor Date: Fri, 29 Sep 2023 09:39:26 -0400 Subject: [PATCH] Fix missing loc in date-input test (#615) * Fix missing loc in date-input test * Remove unnecessary prop * Bump patch --- package.json | 2 +- test/forms/inputs/date-input.test.js | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c07b3c7e..47bcf48e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@launchpadlab/lp-components", - "version": "9.2.0", + "version": "9.2.1", "engines": { "node": "^18.12" }, diff --git a/test/forms/inputs/date-input.test.js b/test/forms/inputs/date-input.test.js index b531d05d..24f2ca73 100644 --- a/test/forms/inputs/date-input.test.js +++ b/test/forms/inputs/date-input.test.js @@ -86,7 +86,7 @@ test("DateInput defaults tabbable item to today's date", async () => { expect(current).toHaveProperty('tabIndex', 0) }) -test('DateInput sets empty input to an empty string', async () => { +test("DateInput sets empty input to an empty string", async () => { const user = userEvent.setup() const onChange = jest.fn() const props = { input: { ...input, onChange, onBlur: noop }, meta: {} } @@ -97,4 +97,23 @@ test('DateInput sets empty input to an empty string', async () => { expect(onChange).toHaveBeenCalledTimes(1) expect(onChange).toHaveBeenCalledWith('') +}) + +test("DateInput invokes onBlur when focus changes", async () => { + const user = userEvent.setup() + const onBlur = jest.fn() + const onChange = jest.fn() + const props = { input: { ...input, onChange, onBlur }, meta: {} } + + render() + + await user.click(screen.getByRole('textbox')) + + const option = screen + .getAllByRole('option', { selected: false, hidden: false }) + .at(0) + await user.click(option) + await user.tab() + + expect(onBlur).toHaveBeenCalledTimes(1) }) \ No newline at end of file