-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86e283f
commit 794afd8
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
packages/component-library/src/components/form/mt-colorpicker/mt-colorpicker.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { mount } from "@vue/test-utils"; | ||
import userEvent from "@testing-library/user-event"; | ||
import MtColorpicker from "./mt-colorpicker.vue"; | ||
|
||
async function createWrapper(customOptions = {}) { | ||
return mount(MtColorpicker, { | ||
...customOptions, | ||
}); | ||
} | ||
|
||
describe("src/app/component/form/mt-datepicker", () => { | ||
let wrapper: undefined | Awaited<ReturnType<typeof createWrapper>>; | ||
|
||
afterEach(() => { | ||
if (wrapper) { | ||
wrapper.unmount(); | ||
} | ||
}); | ||
|
||
it("opens with keyboard", async () => { | ||
const user = userEvent.setup(); | ||
wrapper = await createWrapper({ attachTo: document.body }); | ||
|
||
// Simulate tabbing to focus the input element | ||
await user.tab(); | ||
const colorPickerInput = wrapper.find(".mt-colorpicker__input"); | ||
const inputElement = colorPickerInput.element as HTMLElement; | ||
|
||
// Assert the input has focus | ||
expect(inputElement).toHaveFocus(); | ||
|
||
// Simulate pressing Enter | ||
await user.keyboard("{Enter}"); | ||
|
||
// Wait for the dropdown to appear | ||
const dropdown = document.querySelector(".mt-floating-ui__content"); | ||
expect(dropdown).toBeTruthy(); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters