Commit 17651e21 authored by Alexander Turinske's avatar Alexander Turinske

Refactor security dashboard getter test mocks

- use cleaner implementation
parent d90a33f4
......@@ -169,8 +169,7 @@ describe('filters actions', () => {
},
].forEach(testCase => {
it(testCase.description, done => {
const mockValue = testCase.returnValue;
getParameterValues.mockImplementation(() => mockValue);
getParameterValues.mockReturnValue(testCase.returnValue);
const state = createState();
testAction(
actions.setHideDismissedToggleInitialState,
......
......@@ -65,26 +65,17 @@ describe('vulnerabilities module getters', () => {
getters.getVulnerabilityHistoryByName(state)(name);
return { getVulnerabilityHistoryByName };
};
const realDate = Date;
beforeEach(() => {
state = createState();
state.vulnerabilitiesHistory = mockHistoryData;
jest.useFakeTimers();
const currentDate = new Date(2019, 1, 2);
global.Date = class extends Date {
constructor(date) {
if (date) {
// eslint-disable-next-line constructor-super
return super(date);
}
return currentDate;
}
};
});
afterEach(() => {
global.Date = realDate;
const mockDate = new Date(2019, 1, 2);
const originalDate = Date;
jest.spyOn(global, 'Date').mockImplementation(() => mockDate);
global.Date.now = originalDate.now;
global.Date.parse = originalDate.parse;
global.Date.UTC = originalDate.UTC;
});
it('should filter the data to the last 30 days and days we have data for', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment