-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added tests for file facets status (#264)
- Loading branch information
Fran McDade
authored and
Fran McDade
committed
Nov 19, 2024
1 parent
9de706f
commit f417016
Showing
3 changed files
with
112 additions
and
24 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,7 +1,31 @@ | ||
import { FILE_MANIFEST_TYPE } from "../../hooks/useFileManifest/common/entities"; | ||
import { | ||
FILE_MANIFEST_TYPE, | ||
FILES_FACETS_STATUS, | ||
} from "../../hooks/useFileManifest/common/entities"; | ||
import { FileManifestState } from "../fileManifestState"; | ||
|
||
export const ENTITIES_FILE_MANIFEST_TYPES: FILE_MANIFEST_TYPE[] = [ | ||
FILE_MANIFEST_TYPE.BULK_DOWNLOAD, | ||
FILE_MANIFEST_TYPE.DOWNLOAD_MANIFEST, | ||
FILE_MANIFEST_TYPE.EXPORT_TO_TERRA, | ||
]; | ||
|
||
export const FILE_MANIFEST_STATE: FileManifestState = { | ||
fileManifestFormat: undefined, | ||
fileManifestType: undefined, | ||
fileSummary: undefined, | ||
fileSummaryFacetName: undefined, | ||
fileSummaryFilters: [], | ||
filesFacets: [], | ||
filesFacetsStatus: FILES_FACETS_STATUS.NOT_STARTED, | ||
filters: [], | ||
isEnabled: false, | ||
isFacetsLoading: false, | ||
isFacetsSuccess: false, | ||
isFileSummaryLoading: false, | ||
isLoading: false, | ||
isSummaryLoading: false, | ||
requestParams: undefined, | ||
requestURL: undefined, | ||
summary: undefined, | ||
}; |
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,84 @@ | ||
import { FILES_FACETS_STATUS } from "../src/hooks/useFileManifest/common/entities"; | ||
import { | ||
FileManifestState, | ||
UpdateFileManifestPayload, | ||
} from "../src/providers/fileManifestState"; | ||
import { FILE_MANIFEST_STATE } from "../src/providers/fileManifestState/constants"; | ||
import { updateFilesFacetsStatus } from "../src/providers/fileManifestState/utils"; | ||
|
||
const FILE_MANIFEST_STATE_NOT_STARTED: FileManifestState = { | ||
...FILE_MANIFEST_STATE, | ||
filesFacetsStatus: FILES_FACETS_STATUS.NOT_STARTED, | ||
}; | ||
|
||
const FILE_MANIFEST_STATE_IN_PROGRESS: FileManifestState = { | ||
...FILE_MANIFEST_STATE, | ||
filesFacetsStatus: FILES_FACETS_STATUS.IN_PROGRESS, | ||
}; | ||
|
||
const FILE_MANIFEST_STATE_COMPLETED: FileManifestState = { | ||
...FILE_MANIFEST_STATE, | ||
filesFacetsStatus: FILES_FACETS_STATUS.COMPLETED, | ||
}; | ||
|
||
const UPDATE_FILE_MANIFEST_PAYLOAD_IDLE = { | ||
isFacetsLoading: false, | ||
isFacetsSuccess: false, | ||
} as UpdateFileManifestPayload; | ||
|
||
const UPDATE_FILE_MANIFEST_PAYLOAD_LOADING = { | ||
isFacetsLoading: true, | ||
isFacetsSuccess: false, | ||
} as UpdateFileManifestPayload; | ||
|
||
const UPDATE_FILE_MANIFEST_PAYLOAD_SUCCESS = { | ||
isFacetsLoading: false, | ||
isFacetsSuccess: true, | ||
} as UpdateFileManifestPayload; | ||
|
||
describe("updateFilesFacetsStatus", () => { | ||
test("files facets NOT_STARTED, request is IDLE", () => { | ||
expect( | ||
updateFilesFacetsStatus( | ||
FILE_MANIFEST_STATE_NOT_STARTED, | ||
UPDATE_FILE_MANIFEST_PAYLOAD_IDLE | ||
) | ||
).toBe(FILES_FACETS_STATUS.NOT_STARTED); | ||
}); | ||
|
||
test("files facets NOT_STARTED, request is LOADING", () => { | ||
expect( | ||
updateFilesFacetsStatus( | ||
FILE_MANIFEST_STATE_NOT_STARTED, | ||
UPDATE_FILE_MANIFEST_PAYLOAD_LOADING | ||
) | ||
).toBe(FILES_FACETS_STATUS.IN_PROGRESS); | ||
}); | ||
|
||
test("files facets IN_PROGRESS, request is LOADING", () => { | ||
expect( | ||
updateFilesFacetsStatus( | ||
FILE_MANIFEST_STATE_IN_PROGRESS, | ||
UPDATE_FILE_MANIFEST_PAYLOAD_LOADING | ||
) | ||
).toBe(FILES_FACETS_STATUS.IN_PROGRESS); | ||
}); | ||
|
||
test("files facets IN_PROGRESS, request is SUCCESS", () => { | ||
expect( | ||
updateFilesFacetsStatus( | ||
FILE_MANIFEST_STATE_IN_PROGRESS, | ||
UPDATE_FILE_MANIFEST_PAYLOAD_SUCCESS | ||
) | ||
).toBe(FILES_FACETS_STATUS.COMPLETED); | ||
}); | ||
|
||
test("files facets COMPLETED, request is SUCCESS", () => { | ||
expect( | ||
updateFilesFacetsStatus( | ||
FILE_MANIFEST_STATE_COMPLETED, | ||
UPDATE_FILE_MANIFEST_PAYLOAD_SUCCESS | ||
) | ||
).toBe(FILES_FACETS_STATUS.COMPLETED); | ||
}); | ||
}); |