diff options
Diffstat (limited to 'spec/frontend/static_site_editor/store/mutations_spec.js')
-rw-r--r-- | spec/frontend/static_site_editor/store/mutations_spec.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/frontend/static_site_editor/store/mutations_spec.js b/spec/frontend/static_site_editor/store/mutations_spec.js new file mode 100644 index 00000000000..c7055fbb2f0 --- /dev/null +++ b/spec/frontend/static_site_editor/store/mutations_spec.js @@ -0,0 +1,52 @@ +import createState from '~/static_site_editor/store/state'; +import mutations from '~/static_site_editor/store/mutations'; +import * as types from '~/static_site_editor/store/mutation_types'; +import { sourceContentTitle as title, sourceContent as content } from '../mock_data'; + +describe('Static Site Editor Store mutations', () => { + let state; + + beforeEach(() => { + state = createState(); + }); + + describe('loadContent', () => { + beforeEach(() => { + mutations[types.LOAD_CONTENT](state); + }); + + it('sets isLoadingContent to true', () => { + expect(state.isLoadingContent).toBe(true); + }); + }); + + describe('receiveContentSuccess', () => { + const payload = { title, content }; + + beforeEach(() => { + mutations[types.RECEIVE_CONTENT_SUCCESS](state, payload); + }); + + it('sets current state to LOADING', () => { + expect(state.isLoadingContent).toBe(false); + }); + + it('sets title', () => { + expect(state.title).toBe(payload.title); + }); + + it('sets content', () => { + expect(state.content).toBe(payload.content); + }); + }); + + describe('receiveContentError', () => { + beforeEach(() => { + mutations[types.RECEIVE_CONTENT_ERROR](state); + }); + + it('sets current state to LOADING_ERROR', () => { + expect(state.isLoadingContent).toBe(false); + }); + }); +}); |