Commit 529abbf8 authored by peterhegman's avatar peterhegman

Refactor specs to use shared variable

parent 17dc93d6
...@@ -44,18 +44,16 @@ describe('Vuex members mutations', () => { ...@@ -44,18 +44,16 @@ describe('Vuex members mutations', () => {
describe('when error has a message', () => { describe('when error has a message', () => {
it('shows error message', () => { it('shows error message', () => {
const error = new Error('Request failed with status code 422'); const error = new Error('Request failed with status code 422');
const message =
'User email "john.smith@gmail.com" does not match the allowed domain of example.com';
error.response = { error.response = {
data: { data: { message },
message:
'User email "john.smith@gmail.com" does not match the allowed domain of example.com',
},
}; };
mutations[types.RECEIVE_MEMBER_ROLE_ERROR](state, { error }); mutations[types.RECEIVE_MEMBER_ROLE_ERROR](state, { error });
expect(state.showError).toBe(true); expect(state.showError).toBe(true);
expect(state.errorMessage).toBe( expect(state.errorMessage).toBe(message);
'User email "john.smith@gmail.com" does not match the allowed domain of example.com',
);
}); });
}); });
}); });
...@@ -90,18 +88,16 @@ describe('Vuex members mutations', () => { ...@@ -90,18 +88,16 @@ describe('Vuex members mutations', () => {
describe('when error has a message', () => { describe('when error has a message', () => {
it('shows error message', () => { it('shows error message', () => {
const error = new Error('Request failed with status code 422'); const error = new Error('Request failed with status code 422');
const message =
'User email "john.smith@gmail.com" does not match the allowed domain of example.com';
error.response = { error.response = {
data: { data: { message },
message:
'User email "john.smith@gmail.com" does not match the allowed domain of example.com',
},
}; };
mutations[types.RECEIVE_MEMBER_EXPIRATION_ERROR](state, { error }); mutations[types.RECEIVE_MEMBER_EXPIRATION_ERROR](state, { error });
expect(state.showError).toBe(true); expect(state.showError).toBe(true);
expect(state.errorMessage).toBe( expect(state.errorMessage).toBe(message);
'User email "john.smith@gmail.com" does not match the allowed domain of example.com',
);
}); });
}); });
}); });
......
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