chore: await tests

Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2022-04-01 14:06:17 +02:00
parent b1190bf676
commit fbee9f49e5
3 changed files with 15 additions and 15 deletions
@@ -68,7 +68,7 @@ describe('SearchModal', () => {
);
expect(query).toHaveBeenCalledTimes(1);
userEvent.keyboard('{esc}');
await userEvent.keyboard('{Escape}');
expect(toggleModal).toHaveBeenCalledTimes(1);
});
@@ -78,19 +78,19 @@ describe('SearchType.Accordion', () => {
await act(() => Promise.resolve());
});
it('should set entire types array when a type is selected', () => {
it('should set entire types array when a type is selected', async () => {
const { getByText } = render(
<SearchContext.Provider value={contextSpy}>
<SearchType.Accordion name={expectedLabel} types={[expectedType]} />
</SearchContext.Provider>,
);
user.click(getByText(expectedType.name));
await user.click(getByText(expectedType.name));
expect(contextSpy.setTypes).toHaveBeenCalledWith([expectedType.value]);
});
it('should reset types array when all is selected', () => {
it('should reset types array when all is selected', async () => {
const { getByText } = render(
<SearchContext.Provider value={contextSpy}>
<SearchType.Accordion
@@ -101,31 +101,31 @@ describe('SearchType.Accordion', () => {
</SearchContext.Provider>,
);
user.click(getByText('All'));
await user.click(getByText('All'));
expect(contextSpy.setTypes).toHaveBeenCalledWith([]);
});
it('should reset page cursor when a new type is selected', () => {
it('should reset page cursor when a new type is selected', async () => {
const { getByText } = render(
<SearchContext.Provider value={contextSpy}>
<SearchType.Accordion name={expectedLabel} types={[expectedType]} />
</SearchContext.Provider>,
);
user.click(getByText(expectedType.name));
await user.click(getByText(expectedType.name));
expect(contextSpy.setPageCursor).toHaveBeenCalledWith(undefined);
});
it('should collapse when a new type is selected', () => {
it('should collapse when a new type is selected', async () => {
const { getByText, queryByText } = render(
<SearchContext.Provider value={contextSpy}>
<SearchType.Accordion name={expectedLabel} types={[expectedType]} />
</SearchContext.Provider>,
);
user.click(getByText(expectedType.name));
await user.click(getByText(expectedType.name));
expect(queryByText('Collapse')).not.toBeInTheDocument();
});
@@ -70,19 +70,19 @@ describe('SearchType.Tabs', () => {
await act(() => Promise.resolve());
});
it('should set entire types array when a type is selected', () => {
it('should set entire types array when a type is selected', async () => {
const { getByText } = render(
<SearchContext.Provider value={contextSpy}>
<SearchType.Tabs types={[expectedType]} />
</SearchContext.Provider>,
);
user.click(getByText(expectedType.name));
await user.click(getByText(expectedType.name));
expect(contextSpy.setTypes).toHaveBeenCalledWith([expectedType.value]);
});
it('should reset types array when all is selected', () => {
it('should reset types array when all is selected', async () => {
const { getByText } = render(
<SearchContext.Provider value={contextSpy}>
<SearchType.Tabs
@@ -92,19 +92,19 @@ describe('SearchType.Tabs', () => {
</SearchContext.Provider>,
);
user.click(getByText('All'));
await user.click(getByText('All'));
expect(contextSpy.setTypes).toHaveBeenCalledWith([]);
});
it('should reset page cursor when a new type is selected', () => {
it('should reset page cursor when a new type is selected', async () => {
const { getByText } = render(
<SearchContext.Provider value={contextSpy}>
<SearchType.Tabs types={[expectedType]} />
</SearchContext.Provider>,
);
user.click(getByText(expectedType.name));
await user.click(getByText(expectedType.name));
expect(contextSpy.setPageCursor).toHaveBeenCalledWith(undefined);
});