debian-mirror-gitlab/spec/frontend/ide/stores/plugins/terminal_spec.js

58 lines
1.8 KiB
JavaScript
Raw Normal View History

2022-04-04 11:22:00 +05:30
import Vue from 'vue';
2020-06-23 00:09:42 +05:30
import Vuex from 'vuex';
import { TEST_HOST } from 'helpers/test_constants';
import terminalModule from '~/ide/stores/modules/terminal';
import { SET_BRANCH_WORKING_REFERENCE } from '~/ide/stores/mutation_types';
2021-03-11 19:13:27 +05:30
import createTerminalPlugin from '~/ide/stores/plugins/terminal';
2020-06-23 00:09:42 +05:30
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`,
};
2022-04-04 11:22:00 +05:30
Vue.use(Vuex);
2020-06-23 00:09:42 +05:30
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');
});
});