-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
3 changed files
with
149 additions
and
2 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
...app/src/components/molecules/menu-option-selection-all/menu-option-selection-all.spec.tsx
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,75 @@ | ||
import { fireEvent, render } from "@testing-library/react"; | ||
import { MenuOptionSelectionAll } from "./menu-option-selection-all"; | ||
|
||
describe("MenuOptionSelectionAll", () => { | ||
it("renders", () => { | ||
render( | ||
<MenuOptionSelectionAll | ||
select={[]} | ||
state={{} as any} | ||
allSelection={() => {}} | ||
/> | ||
); | ||
}); | ||
|
||
it("renders 2", () => { | ||
render( | ||
<MenuOptionSelectionAll | ||
select={[]} | ||
state={ | ||
{ | ||
fileIndexItems: [] | ||
} as any | ||
} | ||
allSelection={() => {}} | ||
/> | ||
); | ||
}); | ||
|
||
it("keyDown tab skipped", () => { | ||
const allSelection = jest.fn(); | ||
const component = render( | ||
<MenuOptionSelectionAll | ||
select={[]} | ||
state={ | ||
{ | ||
fileIndexItems: [] | ||
} as any | ||
} | ||
allSelection={allSelection} | ||
/> | ||
); | ||
console.log(component.container.innerHTML); | ||
|
||
const allItem = component.queryByTestId("select-all") as HTMLElement; | ||
expect(allItem).toBeTruthy(); | ||
|
||
fireEvent.keyDown(allItem, { | ||
key: "Tab" | ||
}); | ||
|
||
expect(allSelection).toBeCalledTimes(0); | ||
}); | ||
|
||
it("keyDown enter continue", () => { | ||
const allSelection = jest.fn(); | ||
const component = render( | ||
<MenuOptionSelectionAll | ||
select={[]} | ||
state={ | ||
{ | ||
fileIndexItems: [] | ||
} as any | ||
} | ||
allSelection={allSelection} | ||
/> | ||
); | ||
|
||
fireEvent.keyDown( | ||
component.queryByTestId("undo-selection") as HTMLElement, | ||
{ key: "Enter" } | ||
); | ||
|
||
expect(allSelection).toBeCalledTimes(1); | ||
}); | ||
}); |
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
72 changes: 72 additions & 0 deletions
72
...p/src/components/molecules/menu-option-selection-undo/menu-option-selection-undo.spec.tsx
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,72 @@ | ||
import { fireEvent, render } from "@testing-library/react"; | ||
import { MenuOptionSelectionUndo } from "./menu-option-selection-undo"; | ||
|
||
describe("MenuOptionSelectionUndo", () => { | ||
it("renders", () => { | ||
render( | ||
<MenuOptionSelectionUndo | ||
select={[]} | ||
state={{} as any} | ||
undoSelection={() => {}} | ||
/> | ||
); | ||
}); | ||
|
||
it("renders 2", () => { | ||
render( | ||
<MenuOptionSelectionUndo | ||
select={[]} | ||
state={ | ||
{ | ||
fileIndexItems: [] | ||
} as any | ||
} | ||
undoSelection={() => {}} | ||
/> | ||
); | ||
}); | ||
|
||
it("keyDown tab skipped", () => { | ||
const undoSelection = jest.fn(); | ||
const component = render( | ||
<MenuOptionSelectionUndo | ||
select={[]} | ||
state={ | ||
{ | ||
fileIndexItems: [] | ||
} as any | ||
} | ||
undoSelection={undoSelection} | ||
/> | ||
); | ||
|
||
fireEvent.keyDown( | ||
component.queryByTestId("undo-selection") as HTMLElement, | ||
{ key: "Tab" } | ||
); | ||
|
||
expect(undoSelection).toBeCalledTimes(0); | ||
}); | ||
|
||
it("keyDown enter continue", () => { | ||
const undoSelection = jest.fn(); | ||
const component = render( | ||
<MenuOptionSelectionUndo | ||
select={[]} | ||
state={ | ||
{ | ||
fileIndexItems: [] | ||
} as any | ||
} | ||
undoSelection={undoSelection} | ||
/> | ||
); | ||
|
||
fireEvent.keyDown( | ||
component.queryByTestId("undo-selection") as HTMLElement, | ||
{ key: "Enter" } | ||
); | ||
|
||
expect(undoSelection).toBeCalledTimes(1); | ||
}); | ||
}); |