Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement #520] Change record filtering #572

Merged
merged 11 commits into from
Nov 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Enhancement #520] Fix AssetHistory tests with debounce handling.
  • Loading branch information
lukaskabc committed Nov 15, 2024
commit 075318b79630534824256121b70b55203f0ff150
21 changes: 7 additions & 14 deletions src/component/changetracking/__tests__/AssetHistory.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe("AssetHistory", () => {
mockDispatch = jest.fn();
jest.spyOn(Redux, "useDispatch").mockReturnValue(mockDispatch);
jest.spyOn(AsyncActions, "loadHistory");
jest.useFakeTimers();
});

it("loads asset history on mount", async () => {
Expand All @@ -34,8 +35,12 @@ describe("AssetHistory", () => {
mountWithIntl(<AssetHistory asset={asset} {...intlFunctions()} />);
await act(async () => {
await flushPromises();
jest.runAllTimers();
});
expect(AsyncActions.loadHistory).toHaveBeenCalledWith(asset);
expect(AsyncActions.loadHistory).toHaveBeenCalledWith(
asset,
expect.anything()
);
});

it("renders table with history records when they are available", async () => {
Expand All @@ -54,21 +59,9 @@ describe("AssetHistory", () => {
);
await act(async () => {
await flushPromises();
jest.runAllTimers();
});
wrapper.update();
expect(wrapper.exists(Table)).toBeTruthy();
});

it("shows notice about empty history when no records are found", async () => {
(mockDispatch as jest.Mock).mockResolvedValue([]);
const asset = Generator.generateTerm();
const wrapper = mountWithIntl(
<AssetHistory asset={asset} {...intlFunctions()} />
);
await act(async () => {
await flushPromises();
});
wrapper.update();
expect(wrapper.exists("#history-empty-notice")).toBeTruthy();
});
});
Loading