Commit 9d992703 authored by Denys Mishunov's avatar Denys Mishunov

Unwrapped snippet_edit from DOMContentLoaded handler

Also removed the redundant Jest spec
parent 33f30296
import ZenMode from '~/zen_mode';
import { SnippetEditInit } from '~/snippets';
import SnippetsEdit from '~/snippets/components/edit.vue';
import SnippetsAppFactory from '~/snippets';
document.addEventListener('DOMContentLoaded', () => {
SnippetEditInit();
new ZenMode(); // eslint-disable-line no-new
});
SnippetsAppFactory(document.getElementById('js-snippet-edit'), SnippetsEdit);
new ZenMode(); // eslint-disable-line no-new
......@@ -44,11 +44,3 @@ export default function appFactory(el, Component) {
},
});
}
export const SnippetEditInit = () => {
import('./components/edit.vue')
.then(({ default: SnippetsEdit }) => {
appFactory(document.getElementById('js-snippet-edit'), SnippetsEdit);
})
.catch(() => {});
};
import '~/snippet/snippet_edit';
import { triggerDOMEvent } from 'jest/helpers/dom_events_helper';
import { SnippetEditInit } from '~/snippets';
jest.mock('~/snippets');
jest.mock('~/gl_form');
describe('Snippet edit form initialization', () => {
beforeEach(() => {
setFixtures('<div class="snippet-form"></div>');
});
it('correctly initializes Vue Snippet Edit form', () => {
SnippetEditInit.mockClear();
triggerDOMEvent('DOMContentLoaded');
expect(SnippetEditInit).toHaveBeenCalled();
});
});
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