-
-
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
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...ponents/molecules/menu-option-rotate-image-90/internal/trigger-file-hash-request.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,37 @@ | ||
import { act } from "react"; | ||
import { IDetailView } from "../../../../interfaces/IDetailView"; | ||
import { Orientation } from "../../../../interfaces/IFileIndexItem"; | ||
import * as RequestNewFileHash from "./request-new-filehash"; | ||
import { TriggerFileHashRequest } from "./trigger-file-hash-request"; | ||
|
||
describe("TriggerFileHashRequest", () => { | ||
const state: IDetailView = { | ||
subPath: "/test/image.jpg", | ||
fileIndexItem: { | ||
fileHash: "123", | ||
filePath: "/test/image.jpg", | ||
orientation: Orientation.Horizontal | ||
} | ||
} as IDetailView; | ||
|
||
it("returns immediately when the file hash changes on the first attempt", () => { | ||
jest.useFakeTimers(); | ||
|
||
const requestSpy = jest | ||
.spyOn(RequestNewFileHash, "RequestNewFileHash") | ||
.mockResolvedValueOnce(true); | ||
|
||
const setIsLoading = jest.fn(); | ||
TriggerFileHashRequest(state, setIsLoading, jest.fn(), 1, 1); | ||
|
||
act(() => { | ||
jest.advanceTimersByTime(100); | ||
}); | ||
|
||
console.log("after TriggerFileHashRequest"); | ||
|
||
jest.advanceTimersByTime(1); | ||
jest.runAllTimers(); | ||
expect(requestSpy).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |