diff options
author | Natalia Tepluhina <tarya.se@gmail.com> | 2019-04-19 16:58:45 +0300 |
---|---|---|
committer | Natalia Tepluhina <tarya.se@gmail.com> | 2019-04-19 17:14:29 +0300 |
commit | 9ede2e5eb920ca43d6fdb0c7553121dddb9d4f21 (patch) | |
tree | c276b30ef6ff9edaa2c024e92c6e94160c0a6b63 | |
parent | 6be2045bd53fe55c5f60438384b73108a3a25d87 (diff) | |
download | gitlab-ce-9ede2e5eb920ca43d6fdb0c7553121dddb9d4f21.tar.gz |
Fixed mutations spec
-rw-r--r-- | spec/frontend/ide/stores/modules/file_templates/mutations_spec.js | 45 | ||||
-rw-r--r-- | spec/javascripts/ide/stores/modules/file_templates/mutations_spec.js | 64 |
2 files changed, 32 insertions, 77 deletions
diff --git a/spec/frontend/ide/stores/modules/file_templates/mutations_spec.js b/spec/frontend/ide/stores/modules/file_templates/mutations_spec.js index 8e8b7f06ca2..086d7b55968 100644 --- a/spec/frontend/ide/stores/modules/file_templates/mutations_spec.js +++ b/spec/frontend/ide/stores/modules/file_templates/mutations_spec.js @@ -2,6 +2,9 @@ import createState from '~/ide/stores/modules/file_templates/state'; import * as types from '~/ide/stores/modules/file_templates/mutation_types'; import mutations from '~/ide/stores/modules/file_templates/mutations'; +const mockFileTemplates = [['MIT'], ['CC']]; +const mockTemplateType = 'test'; + describe('IDE file templates mutations', () => { let state; @@ -9,12 +12,22 @@ describe('IDE file templates mutations', () => { state = createState(); }); - describe(`${types.REQUEST_TEMPLATE_TYPES}`, () => { - it('sets isLoading', () => { + describe(types.REQUEST_TEMPLATE_TYPES, () => { + it('sets loading to true', () => { + state.isLoading = false; + mutations[types.REQUEST_TEMPLATE_TYPES](state); expect(state.isLoading).toBe(true); }); + + it('sets templates to an empty array', () => { + state.templates = mockFileTemplates; + + mutations[types.REQUEST_TEMPLATE_TYPES](state); + + expect(state.templates).toEqual([]); + }); }); describe(`${types.RECEIVE_TEMPLATE_TYPES_ERROR}`, () => { @@ -31,29 +44,33 @@ describe('IDE file templates mutations', () => { it('sets isLoading to false', () => { state.isLoading = true; - mutations[types.RECEIVE_TEMPLATE_TYPES_SUCCESS](state, []); + mutations[types.RECEIVE_TEMPLATE_TYPES_SUCCESS](state, mockFileTemplates); expect(state.isLoading).toBe(false); }); - it('sets templates', () => { - mutations[types.RECEIVE_TEMPLATE_TYPES_SUCCESS](state, ['test']); + it('sets templates to payload', () => { + state.templates = ['test']; + + mutations[types.RECEIVE_TEMPLATE_TYPES_SUCCESS](state, mockFileTemplates); - expect(state.templates).toEqual(['test']); + expect(state.templates).toEqual(mockFileTemplates); }); }); - describe(`${types.SET_SELECTED_TEMPLATE_TYPE}`, () => { - it('sets selectedTemplateType', () => { - mutations[types.SET_SELECTED_TEMPLATE_TYPE](state, 'type'); + describe(types.SET_SELECTED_TEMPLATE_TYPE, () => { + it('sets templates type to selected type', () => { + state.selectedTemplateType = ''; - expect(state.selectedTemplateType).toBe('type'); + mutations[types.SET_SELECTED_TEMPLATE_TYPE](state, mockTemplateType); + + expect(state.selectedTemplateType).toBe(mockTemplateType); }); - it('clears templates', () => { - state.templates = ['test']; + it('sets templates to empty array', () => { + state.templates = mockFileTemplates; - mutations[types.SET_SELECTED_TEMPLATE_TYPE](state, 'type'); + mutations[types.SET_SELECTED_TEMPLATE_TYPE](state, mockTemplateType); expect(state.templates).toEqual([]); }); @@ -61,6 +78,8 @@ describe('IDE file templates mutations', () => { describe(`${types.SET_UPDATE_SUCCESS}`, () => { it('sets updateSuccess', () => { + state.updateSuccess = false; + mutations[types.SET_UPDATE_SUCCESS](state, true); expect(state.updateSuccess).toBe(true); diff --git a/spec/javascripts/ide/stores/modules/file_templates/mutations_spec.js b/spec/javascripts/ide/stores/modules/file_templates/mutations_spec.js deleted file mode 100644 index 5a9c72e929b..00000000000 --- a/spec/javascripts/ide/stores/modules/file_templates/mutations_spec.js +++ /dev/null @@ -1,64 +0,0 @@ -import state from '~/ide/stores/modules/file_templates/state'; -import mutations from '~/ide/stores/modules/file_templates/mutations'; -import * as types from '~/ide/stores/modules/file_templates/mutation_types'; - -const mockFileTemplates = [['MIT'], ['CC']]; -const mockTemplateType = 'test'; - -describe('IDE file templates mutations', () => { - let mockedState; - - beforeEach(() => { - mockedState = state(); - }); - - describe(types.REQUEST_TEMPLATE_TYPES, () => { - it('sets loading to true', () => { - mutations[types.REQUEST_TEMPLATE_TYPES](mockedState); - - expect(mockedState.isLoading).toBe(true); - }); - - it('sets templates to an empty array', () => { - mutations[types.REQUEST_TEMPLATE_TYPES](mockedState); - - expect(mockedState.templates).toEqual([]); - }); - }); - - describe(types.RECEIVE_TEMPLATE_TYPES_ERROR, () => { - it('sets loading to false', () => { - mutations[types.RECEIVE_TEMPLATE_TYPES_ERROR](mockedState); - - expect(mockedState.isLoading).toBe(false); - }); - }); - - describe(types.RECEIVE_TEMPLATE_TYPES_SUCCESS, () => { - it('sets templates loading to false', () => { - mutations[types.RECEIVE_TEMPLATE_TYPES_SUCCESS](mockedState, mockFileTemplates); - - expect(mockedState.isLoading).toBe(false); - }); - - it('sets templates to payload', () => { - mutations[types.RECEIVE_TEMPLATE_TYPES_SUCCESS](mockedState, mockFileTemplates); - - expect(mockedState.templates).toEqual(mockFileTemplates); - }); - }); - - describe(types.SET_SELECTED_TEMPLATE_TYPE, () => { - it('sets templates type to selected type', () => { - mutations[types.SET_SELECTED_TEMPLATE_TYPE](mockedState, mockTemplateType); - - expect(mockedState.selectedTemplateType).toBe(mockTemplateType); - }); - - it('sets templates to empty array', () => { - mutations[types.SET_SELECTED_TEMPLATE_TYPE](mockedState, mockTemplateType); - - expect(mockedState.templates).toEqual([]); - }); - }); -}); |