Commit f5afac84 authored by Paul Slaughter's avatar Paul Slaughter

Create IDE mirror modules and Vuex plugin

For now, the mirror is mostly stubbed.
It will be implemented in [this issue][1].

[1]: https://gitlab.com/gitlab-org/gitlab-ee/issues/5276
parent 82f1c582
import createDiff from './create_diff';
export const createMirror = () => {
const uploadDiff = () => {
// For now, this is a placeholder.
// It will be implemented in https://gitlab.com/gitlab-org/gitlab-ee/issues/5276
};
return {
upload(state) {
uploadDiff(createDiff(state));
},
};
};
export default createMirror();
import eventHub from '~/ide/eventhub';
import mirror from '../../lib/mirror';
export default function createMirrorPlugin() {
return store => {
eventHub.$on('editor.save', () => mirror.upload(store.state));
};
}
import eventHub from '~/ide/eventhub';
import { createStore } from '~/ide/stores';
import createMirrorPlugin from 'ee/ide/stores/plugins/mirror';
import mirror from 'ee/ide/lib/mirror';
jest.mock('ee/ide/lib/mirror');
describe('EE IDE stores/plugins/mirror', () => {
let store;
let plugin;
beforeEach(() => {
store = createStore();
plugin = createMirrorPlugin();
plugin(store);
});
it('does not initally call upload', () => {
expect(mirror.upload).not.toHaveBeenCalled();
});
it('uploads on editor.save event', () => {
eventHub.$emit('editor.save');
expect(mirror.upload).toHaveBeenCalledWith(store.state);
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment