Commit 3aee8089 authored by Miguel Rincon's avatar Miguel Rincon

Remove repeating dispatch and commit mocks

parent d9a1e681
...@@ -62,11 +62,17 @@ describe('Monitoring store actions', () => { ...@@ -62,11 +62,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));
...@@ -199,12 +205,8 @@ describe('Monitoring store actions', () => { ...@@ -199,12 +205,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';
}); });
...@@ -291,14 +293,6 @@ describe('Monitoring store actions', () => { ...@@ -291,14 +293,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 });
...@@ -358,13 +352,8 @@ describe('Monitoring store actions', () => { ...@@ -358,13 +352,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