Commit a055c03a authored by Tim Zallmann's avatar Tim Zallmann

Merge branch 'mrincon-refactor-repeating-mocks-actions' into 'master'

Remove repeating dispatch and commit mocks

See merge request gitlab-org/gitlab!35203
parents 7e801552 3aee8089
...@@ -63,11 +63,17 @@ describe('Monitoring store actions', () => { ...@@ -63,11 +63,17 @@ describe('Monitoring store actions', () => {
let store; let store;
let state; let state;
let dispatch;
let commit;
beforeEach(() => { beforeEach(() => {
store = createStore({ getters }); store = createStore({ getters });
state = store.state.monitoringDashboard; state = store.state.monitoringDashboard;
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
commit = jest.fn();
dispatch = jest.fn();
jest.spyOn(commonUtils, 'backOff').mockImplementation(callback => { jest.spyOn(commonUtils, 'backOff').mockImplementation(callback => {
const q = new Promise((resolve, reject) => { const q = new Promise((resolve, reject) => {
const stop = arg => (arg instanceof Error ? reject(arg) : resolve(arg)); const stop = arg => (arg instanceof Error ? reject(arg) : resolve(arg));
...@@ -200,12 +206,8 @@ describe('Monitoring store actions', () => { ...@@ -200,12 +206,8 @@ describe('Monitoring store actions', () => {
// Metrics dashboard // Metrics dashboard
describe('fetchDashboard', () => { describe('fetchDashboard', () => {
let dispatch;
let commit;
const response = metricsDashboardResponse; const response = metricsDashboardResponse;
beforeEach(() => { beforeEach(() => {
dispatch = jest.fn();
commit = jest.fn();
state.dashboardEndpoint = '/dashboard'; state.dashboardEndpoint = '/dashboard';
}); });
...@@ -292,14 +294,6 @@ describe('Monitoring store actions', () => { ...@@ -292,14 +294,6 @@ describe('Monitoring store actions', () => {
}); });
describe('receiveMetricsDashboardSuccess', () => { describe('receiveMetricsDashboardSuccess', () => {
let commit;
let dispatch;
beforeEach(() => {
commit = jest.fn();
dispatch = jest.fn();
});
it('stores groups', () => { it('stores groups', () => {
const response = metricsDashboardResponse; const response = metricsDashboardResponse;
receiveMetricsDashboardSuccess({ state, commit, dispatch }, { response }); receiveMetricsDashboardSuccess({ state, commit, dispatch }, { response });
...@@ -359,13 +353,8 @@ describe('Monitoring store actions', () => { ...@@ -359,13 +353,8 @@ describe('Monitoring store actions', () => {
// Metrics // Metrics
describe('fetchDashboardData', () => { describe('fetchDashboardData', () => {
let commit;
let dispatch;
beforeEach(() => { beforeEach(() => {
jest.spyOn(Tracking, 'event'); jest.spyOn(Tracking, 'event');
commit = jest.fn();
dispatch = jest.fn();
state.timeRange = defaultTimeRange; state.timeRange = defaultTimeRange;
}); });
......
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