diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/frontend/ide/stores/plugins/terminal_spec.js | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/frontend/ide/stores/plugins/terminal_spec.js')
-rw-r--r-- | spec/frontend/ide/stores/plugins/terminal_spec.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/spec/frontend/ide/stores/plugins/terminal_spec.js b/spec/frontend/ide/stores/plugins/terminal_spec.js new file mode 100644 index 00000000000..948c2131fd8 --- /dev/null +++ b/spec/frontend/ide/stores/plugins/terminal_spec.js @@ -0,0 +1,58 @@ +import { createLocalVue } from '@vue/test-utils'; +import Vuex from 'vuex'; +import { TEST_HOST } from 'helpers/test_constants'; +import terminalModule from '~/ide/stores/modules/terminal'; +import createTerminalPlugin from '~/ide/stores/plugins/terminal'; +import { SET_BRANCH_WORKING_REFERENCE } from '~/ide/stores/mutation_types'; + +const TEST_DATASET = { + eeWebTerminalSvgPath: `${TEST_HOST}/web/terminal/svg`, + eeWebTerminalHelpPath: `${TEST_HOST}/web/terminal/help`, + eeWebTerminalConfigHelpPath: `${TEST_HOST}/web/terminal/config/help`, + eeWebTerminalRunnersHelpPath: `${TEST_HOST}/web/terminal/runners/help`, +}; +const localVue = createLocalVue(); +localVue.use(Vuex); + +describe('ide/stores/extend', () => { + let store; + + beforeEach(() => { + const el = document.createElement('div'); + Object.assign(el.dataset, TEST_DATASET); + + store = new Vuex.Store({ + mutations: { + [SET_BRANCH_WORKING_REFERENCE]: () => {}, + }, + }); + + jest.spyOn(store, 'registerModule').mockImplementation(); + jest.spyOn(store, 'dispatch').mockImplementation(); + + const plugin = createTerminalPlugin(el); + + plugin(store); + }); + + it('registers terminal module', () => { + expect(store.registerModule).toHaveBeenCalledWith('terminal', terminalModule()); + }); + + it('dispatches terminal/setPaths', () => { + expect(store.dispatch).toHaveBeenCalledWith('terminal/setPaths', { + webTerminalSvgPath: TEST_DATASET.eeWebTerminalSvgPath, + webTerminalHelpPath: TEST_DATASET.eeWebTerminalHelpPath, + webTerminalConfigHelpPath: TEST_DATASET.eeWebTerminalConfigHelpPath, + webTerminalRunnersHelpPath: TEST_DATASET.eeWebTerminalRunnersHelpPath, + }); + }); + + it(`dispatches terminal/init on ${SET_BRANCH_WORKING_REFERENCE}`, () => { + store.dispatch.mockReset(); + + store.commit(SET_BRANCH_WORKING_REFERENCE); + + expect(store.dispatch).toHaveBeenCalledWith('terminal/init'); + }); +}); |