Commit cf2bca62 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch '262403-unwrap-code' into 'master'

Unwrapped snippet_edit from DOMContentLoaded handler

See merge request gitlab-org/gitlab!45505
parents 4ecea023 9d992703
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