mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
fix(tests): add missing test coverage
This commit is contained in:
@@ -25,20 +25,16 @@ const Fetcher = observer(
|
||||
},
|
||||
markCompleted() {
|
||||
this.completedAt = moment();
|
||||
},
|
||||
forceUpdate() {
|
||||
this.time = moment(0);
|
||||
}
|
||||
},
|
||||
{
|
||||
update: action,
|
||||
markCompleted: action,
|
||||
forceUpdate: action
|
||||
markCompleted: action
|
||||
}
|
||||
);
|
||||
|
||||
getSortSettings = () => {
|
||||
const { alertStore, settingsStore } = this.props;
|
||||
const { settingsStore } = this.props;
|
||||
|
||||
let sortSettings = {
|
||||
useDefaults: false,
|
||||
@@ -55,7 +51,7 @@ const Fetcher = observer(
|
||||
return sortSettings;
|
||||
}
|
||||
|
||||
sortSettings.sortOrder = alertStore.settings.values.sorting.grid.order;
|
||||
sortSettings.sortOrder = settingsStore.gridConfig.config.sortOrder;
|
||||
|
||||
// don't sort if sorting is disabled
|
||||
if (
|
||||
@@ -71,7 +67,7 @@ const Fetcher = observer(
|
||||
: "0"
|
||||
: "";
|
||||
|
||||
if (settingsStore.gridConfig.config.sortLabel === null) {
|
||||
if (settingsStore.gridConfig.config.sortLabel !== null) {
|
||||
sortSettings.sortLabel = settingsStore.gridConfig.config.sortLabel;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +139,88 @@ describe("<Fetcher />", () => {
|
||||
expect(fetchSpy).toHaveBeenCalledTimes(4);
|
||||
});
|
||||
|
||||
it("calls alertStore.fetchWithThrottle with empty sort arguments when sortOrder=default", () => {
|
||||
MockEmptyAPIResponseWithoutFilters();
|
||||
const fetchSpy = jest.spyOn(alertStore, "fetchWithThrottle");
|
||||
settingsStore.gridConfig.config.sortOrder =
|
||||
settingsStore.gridConfig.options.default.value;
|
||||
MountedFetcher();
|
||||
expect(fetchSpy).toHaveBeenCalledWith("", "", "");
|
||||
});
|
||||
|
||||
it("calls alertStore.fetchWithThrottle with correct sort arguments when sortOrder=disabled reverseSort=false", () => {
|
||||
MockEmptyAPIResponseWithoutFilters();
|
||||
const fetchSpy = jest.spyOn(alertStore, "fetchWithThrottle");
|
||||
settingsStore.gridConfig.config.sortOrder =
|
||||
settingsStore.gridConfig.options.disabled.value;
|
||||
settingsStore.gridConfig.config.reverseSort = false;
|
||||
MountedFetcher();
|
||||
expect(fetchSpy).toHaveBeenCalledWith("disabled", "", "");
|
||||
});
|
||||
|
||||
it("calls alertStore.fetchWithThrottle with correct sort arguments when sortOrder=disabled reverseSort=true", () => {
|
||||
MockEmptyAPIResponseWithoutFilters();
|
||||
const fetchSpy = jest.spyOn(alertStore, "fetchWithThrottle");
|
||||
settingsStore.gridConfig.config.sortOrder =
|
||||
settingsStore.gridConfig.options.disabled.value;
|
||||
settingsStore.gridConfig.config.reverseSort = true;
|
||||
MountedFetcher();
|
||||
expect(fetchSpy).toHaveBeenCalledWith("disabled", "", "");
|
||||
});
|
||||
|
||||
it("calls alertStore.fetchWithThrottle with correct sort arguments when sortOrder=startsAt reverseSort=false", () => {
|
||||
MockEmptyAPIResponseWithoutFilters();
|
||||
const fetchSpy = jest.spyOn(alertStore, "fetchWithThrottle");
|
||||
settingsStore.gridConfig.config.sortOrder =
|
||||
settingsStore.gridConfig.options.startsAt.value;
|
||||
settingsStore.gridConfig.config.reverseSort = false;
|
||||
MountedFetcher();
|
||||
expect(fetchSpy).toHaveBeenCalledWith("startsAt", "", "0");
|
||||
});
|
||||
|
||||
it("calls alertStore.fetchWithThrottle with correct sort arguments when sortOrder=startsAt reverseSort=true", () => {
|
||||
MockEmptyAPIResponseWithoutFilters();
|
||||
const fetchSpy = jest.spyOn(alertStore, "fetchWithThrottle");
|
||||
settingsStore.gridConfig.config.sortOrder =
|
||||
settingsStore.gridConfig.options.startsAt.value;
|
||||
settingsStore.gridConfig.config.reverseSort = true;
|
||||
MountedFetcher();
|
||||
expect(fetchSpy).toHaveBeenCalledWith("startsAt", "", "1");
|
||||
});
|
||||
|
||||
it("calls alertStore.fetchWithThrottle with correct sort arguments when sortOrder=label sortLabel=cluster reverseSort=false", () => {
|
||||
MockEmptyAPIResponseWithoutFilters();
|
||||
const fetchSpy = jest.spyOn(alertStore, "fetchWithThrottle");
|
||||
settingsStore.gridConfig.config.sortOrder =
|
||||
settingsStore.gridConfig.options.label.value;
|
||||
settingsStore.gridConfig.config.sortLabel = "cluster";
|
||||
settingsStore.gridConfig.config.reverseSort = false;
|
||||
MountedFetcher();
|
||||
expect(fetchSpy).toHaveBeenCalledWith("label", "cluster", "0");
|
||||
});
|
||||
|
||||
it("calls alertStore.fetchWithThrottle with correct sort arguments when sortOrder=label sortLabel=job reverseSort=true", () => {
|
||||
MockEmptyAPIResponseWithoutFilters();
|
||||
const fetchSpy = jest.spyOn(alertStore, "fetchWithThrottle");
|
||||
settingsStore.gridConfig.config.sortOrder =
|
||||
settingsStore.gridConfig.options.label.value;
|
||||
settingsStore.gridConfig.config.sortLabel = "job";
|
||||
settingsStore.gridConfig.config.reverseSort = true;
|
||||
MountedFetcher();
|
||||
expect(fetchSpy).toHaveBeenCalledWith("label", "job", "1");
|
||||
});
|
||||
|
||||
it("calls alertStore.fetchWithThrottle with correct sort arguments when sortOrder=label sortLabel=instance reverseSort=null", () => {
|
||||
MockEmptyAPIResponseWithoutFilters();
|
||||
const fetchSpy = jest.spyOn(alertStore, "fetchWithThrottle");
|
||||
settingsStore.gridConfig.config.sortOrder =
|
||||
settingsStore.gridConfig.options.label.value;
|
||||
settingsStore.gridConfig.config.sortLabel = "instance";
|
||||
settingsStore.gridConfig.config.reverseSort = null;
|
||||
MountedFetcher();
|
||||
expect(fetchSpy).toHaveBeenCalledWith("label", "instance", "");
|
||||
});
|
||||
|
||||
it("internal timer is armed after render", () => {
|
||||
const tree = MountedFetcher();
|
||||
const instance = tree.instance();
|
||||
|
||||
Reference in New Issue
Block a user