Skip to content

Commit

Permalink
remove outdated test
Browse files Browse the repository at this point in the history
  • Loading branch information
MathildeDuboille committed Apr 1, 2020
1 parent 3b1a3da commit 099fad0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
28 changes: 19 additions & 9 deletions frontend/src/__fixtures__/state.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { PersistState } from 'redux-persist/es/types';
import { RootState } from "redux/types";

export const state = {
lead: {
leadSubmission: null,
},
export const state: RootState = {
login: {
isAuthenticated: false,
loginError: 'some login error message',
Expand All @@ -25,20 +23,32 @@ export const state = {
entities: {
projects: {
byId: null,
toastrDisplay: ''
},
pages: {
byId: null,
}
},
scripts: {
byId: null,
},
audits: {
runningAuditByPageOrScriptId: {}
},
auditParameters: {
byId: null,
},
auditStatusHistories: {
byPageOrScriptIdAndAuditParametersId: null,
},
},
auditResults: {
isLoading: false,
byAuditId: {},
sortedByPageId: {},
sortedByScriptId: {},
},
content: {
lastUpdateOfWhatsNew: null,
lastClickOnWhatsNew: null,
},
user: null,
toastr: {
toastrs: []
},
};
14 changes: 3 additions & 11 deletions frontend/src/redux/parameters/__tests__/selectors.test.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
import { state } from '__fixtures__/state';
import {MetricType} from "redux/auditResults/types";
import * as selectors from 'redux/selectors';
import { getMetricsToDisplay } from '../selectors';

const projectId = '12345';
const defaultMetrics = [
'WPTMetricFirstViewTTI',
'WPTMetricFirstViewSpeedIndex',
'WPTMetricFirstViewLoadTime',
];
const customMetrics = ['WPTMetricFirstViewFirstPaint', 'WPTMetricRepeatViewFirstPaint'];
const customMetrics: MetricType[] = ['WPTMetricFirstViewFirstPaint', 'WPTMetricRepeatViewFirstPaint'];
const initialState = {
...state,
parameters: {
...state.parameters,
displayedMetrics: { [projectId]: customMetrics },
},
};

describe('Parameters selectors', () => {
describe('getMetricsToDisplay function', () => {
it('Should return the default value when the projectId does not exist in the paramaters store', () => {
const mockedGetCurrentProjectId = jest.spyOn(selectors, 'getCurrentProjectId');
mockedGetCurrentProjectId.mockReturnValue('I do not exist in the paramaters store');
expect(getMetricsToDisplay(initialState)).toEqual(defaultMetrics);
});
it('Should return the custom value when the projectId exists', () => {
const mockedGetCurrentProjectId = jest.spyOn(selectors, 'getCurrentProjectId');
mockedGetCurrentProjectId.mockReturnValue(projectId);
Expand Down

0 comments on commit 099fad0

Please sign in to comment.