Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/gl_form_spec.js')
-rw-r--r--spec/frontend/gl_form_spec.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/frontend/gl_form_spec.js b/spec/frontend/gl_form_spec.js
index ab5627ce216..6ad9d9f4338 100644
--- a/spec/frontend/gl_form_spec.js
+++ b/spec/frontend/gl_form_spec.js
@@ -6,6 +6,47 @@ import '~/lib/utils/common_utils';
describe('GLForm', () => {
const testContext = {};
+ const mockGl = {
+ GfmAutoComplete: {
+ dataSources: {
+ commands: '/group/projects/-/autocomplete_sources/commands',
+ },
+ },
+ };
+
+ describe('Setting up GfmAutoComplete', () => {
+ describe('setupForm', () => {
+ let setupFormSpy;
+
+ beforeEach(() => {
+ setupFormSpy = jest.spyOn(GLForm.prototype, 'setupForm');
+
+ testContext.form = $('<form class="gfm-form"><textarea class="js-gfm-input"></form>');
+ testContext.textarea = testContext.form.find('textarea');
+ });
+
+ it('should be called with the global data source `windows.gl`', () => {
+ window.gl = { ...mockGl };
+ testContext.glForm = new GLForm(testContext.form, {}, false);
+
+ expect(setupFormSpy).toHaveBeenCalledTimes(1);
+ expect(setupFormSpy).toHaveBeenCalledWith(window.gl.GfmAutoComplete.dataSources, false);
+ });
+
+ it('should be called with the provided custom data source', () => {
+ window.gl = { ...mockGl };
+
+ const customDataSources = {
+ foobar: '/group/projects/-/autocomplete_sources/foobar',
+ };
+
+ testContext.glForm = new GLForm(testContext.form, {}, false, customDataSources);
+
+ expect(setupFormSpy).toHaveBeenCalledTimes(1);
+ expect(setupFormSpy).toHaveBeenCalledWith(customDataSources, false);
+ });
+ });
+ });
describe('when instantiated', () => {
beforeEach(() => {