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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

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 = {
2022-06-21 17:19:12 +05:30
webTerminalSvgPath: `${TEST_HOST}/web/terminal/svg`,
webTerminalHelpPath: `${TEST_HOST}/web/terminal/help`,
webTerminalConfigHelpPath: `${TEST_HOST}/web/terminal/config/help`,
webTerminalRunnersHelpPath: `${TEST_HOST}/web/terminal/runners/help`,
2020-06-23 00:09:42 +05:30
};
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', {
2022-06-21 17:19:12 +05:30
webTerminalSvgPath: TEST_DATASET.webTerminalSvgPath,
webTerminalHelpPath: TEST_DATASET.webTerminalHelpPath,
webTerminalConfigHelpPath: TEST_DATASET.webTerminalConfigHelpPath,
webTerminalRunnersHelpPath: TEST_DATASET.webTerminalRunnersHelpPath,
2020-06-23 00:09:42 +05:30
});
});
it(`dispatches terminal/init on ${SET_BRANCH_WORKING_REFERENCE}`, () => {
store.dispatch.mockReset();
store.commit(SET_BRANCH_WORKING_REFERENCE);
expect(store.dispatch).toHaveBeenCalledWith('terminal/init');
});
});