Remove inclusive JS imports
This commit is contained in:
parent
421e41c9ce
commit
001c904f28
6 changed files with 20 additions and 34 deletions
|
@ -1,4 +1,4 @@
|
|||
import * as DropLab from './droplab/drop_lab';
|
||||
import DropLab from './droplab/drop_lab';
|
||||
import ISetter from './droplab/plugins/input_setter';
|
||||
|
||||
// Todo: Remove this when fixing issue in input_setter plugin
|
||||
|
@ -15,7 +15,7 @@ class CloseReopenReportToggle {
|
|||
this.reopenItem = this.dropdownList.querySelector('.reopen-item');
|
||||
this.closeItem = this.dropdownList.querySelector('.close-item');
|
||||
|
||||
this.droplab = new DropLab.default();
|
||||
this.droplab = new DropLab();
|
||||
|
||||
const config = this.setConfig();
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import '~/lib/utils/text_utility';
|
|||
import './flash';
|
||||
import './task_list';
|
||||
import CreateMergeRequestDropdown from './create_merge_request_dropdown';
|
||||
import * as CloseReopenReportToggle from './close_reopen_report_toggle';
|
||||
import CloseReopenReportToggle from './close_reopen_report_toggle';
|
||||
|
||||
class Issue {
|
||||
constructor() {
|
||||
|
@ -98,7 +98,7 @@ class Issue {
|
|||
const dropdownList = container.querySelector('.js-issuable-close-menu');
|
||||
const button = container.querySelector('.js-issuable-close-button');
|
||||
|
||||
this.closeReopenReportToggle = new CloseReopenReportToggle.default({
|
||||
this.closeReopenReportToggle = new CloseReopenReportToggle({
|
||||
dropdownTrigger,
|
||||
dropdownList,
|
||||
button,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
import 'vendor/jquery.waitforimages';
|
||||
import './task_list';
|
||||
import './merge_request_tabs';
|
||||
import * as CloseReopenReportToggle from './close_reopen_report_toggle';
|
||||
import CloseReopenReportToggle from './close_reopen_report_toggle';
|
||||
|
||||
(function() {
|
||||
this.MergeRequest = (function() {
|
||||
|
@ -130,7 +130,7 @@ import * as CloseReopenReportToggle from './close_reopen_report_toggle';
|
|||
const dropdownList = container.querySelector('.js-issuable-close-menu');
|
||||
const button = container.querySelector('.js-issuable-close-button');
|
||||
|
||||
const closeReopenReportToggle = new CloseReopenReportToggle.default({
|
||||
const closeReopenReportToggle = new CloseReopenReportToggle({
|
||||
dropdownTrigger,
|
||||
dropdownList,
|
||||
button,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import CloseReopenReportToggle from '~/close_reopen_report_toggle';
|
||||
import * as DropLab from '~/droplab/drop_lab';
|
||||
import DropLab from '~/droplab/drop_lab';
|
||||
|
||||
describe('CloseReopenReportToggle', () => {
|
||||
describe('class constructor', () => {
|
||||
|
@ -32,7 +32,6 @@ describe('CloseReopenReportToggle', () => {
|
|||
describe('initDroplab', () => {
|
||||
let closeReopenReportToggle;
|
||||
const dropdownList = jasmine.createSpyObj('dropdownList', ['querySelector']);
|
||||
const droplab = jasmine.createSpyObj('droplab', ['init']);
|
||||
const dropdownTrigger = {};
|
||||
const button = {};
|
||||
const reopenItem = {};
|
||||
|
@ -40,7 +39,7 @@ describe('CloseReopenReportToggle', () => {
|
|||
const config = {};
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(DropLab, 'default').and.returnValue(droplab);
|
||||
spyOn(DropLab.prototype, 'init');
|
||||
dropdownList.querySelector.and.returnValues(reopenItem, closeItem);
|
||||
|
||||
closeReopenReportToggle = new CloseReopenReportToggle({
|
||||
|
@ -61,17 +60,16 @@ describe('CloseReopenReportToggle', () => {
|
|||
expect(closeReopenReportToggle.closeItem).toBe(closeItem);
|
||||
});
|
||||
|
||||
it('instantiates DropLab and set .droplab', () => {
|
||||
expect(DropLab.default).toHaveBeenCalled();
|
||||
expect(closeReopenReportToggle.droplab).toBe(droplab);
|
||||
it('sets .droplab', () => {
|
||||
expect(closeReopenReportToggle.droplab).toEqual(jasmine.any(Object));
|
||||
});
|
||||
|
||||
it('calls .setConfig', () => {
|
||||
expect(closeReopenReportToggle.setConfig).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('calls .droplab.init', () => {
|
||||
expect(droplab.init).toHaveBeenCalledWith(
|
||||
it('calls droplab.init', () => {
|
||||
expect(DropLab.prototype.init).toHaveBeenCalledWith(
|
||||
dropdownTrigger,
|
||||
dropdownList,
|
||||
jasmine.any(Array),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* eslint-disable space-before-function-paren, one-var, one-var-declaration-per-line, no-use-before-define, comma-dangle, max-len */
|
||||
import Issue from '~/issue';
|
||||
import * as CloseReopenReportToggle from '~/close_reopen_report_toggle';
|
||||
import CloseReopenReportToggle from '~/close_reopen_report_toggle';
|
||||
import '~/lib/utils/text_utility';
|
||||
|
||||
describe('Issue', function() {
|
||||
|
@ -208,15 +208,14 @@ describe('Issue', function() {
|
|||
});
|
||||
|
||||
describe('initCloseReopenReport', () => {
|
||||
it('inits a new CloseReopenReportToggle instance and calls .initDroplab', () => {
|
||||
it('calls .initDroplab', () => {
|
||||
const container = jasmine.createSpyObj('container', ['querySelector']);
|
||||
const closeReopenReportToggle = jasmine.createSpyObj('closeReopenReportToggle', ['initDroplab']);
|
||||
const dropdownTrigger = {};
|
||||
const dropdownList = {};
|
||||
const button = {};
|
||||
|
||||
spyOn(document, 'querySelector').and.returnValue(container);
|
||||
spyOn(CloseReopenReportToggle, 'default').and.returnValue(closeReopenReportToggle);
|
||||
spyOn(CloseReopenReportToggle.prototype, 'initDroplab');
|
||||
container.querySelector.and.returnValues(dropdownTrigger, dropdownList, button);
|
||||
|
||||
Issue.prototype.initCloseReopenReport();
|
||||
|
@ -225,12 +224,7 @@ describe('Issue', function() {
|
|||
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-toggle');
|
||||
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-menu');
|
||||
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-button');
|
||||
expect(CloseReopenReportToggle.default).toHaveBeenCalledWith({
|
||||
dropdownTrigger,
|
||||
dropdownList,
|
||||
button,
|
||||
});
|
||||
expect(closeReopenReportToggle.initDroplab).toHaveBeenCalled();
|
||||
expect(CloseReopenReportToggle.prototype.initDroplab).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/* global MergeRequest */
|
||||
|
||||
import '~/merge_request';
|
||||
import * as CloseReopenReportToggle from '~/close_reopen_report_toggle';
|
||||
import CloseReopenReportToggle from '~/close_reopen_report_toggle';
|
||||
|
||||
(function() {
|
||||
describe('MergeRequest', function() {
|
||||
|
@ -40,15 +40,14 @@ import * as CloseReopenReportToggle from '~/close_reopen_report_toggle';
|
|||
});
|
||||
|
||||
describe('initCloseReopenReport', () => {
|
||||
it('inits a new CloseReopenReportToggle instance and calls .initDroplab', () => {
|
||||
it('calls .initDroplab', () => {
|
||||
const container = jasmine.createSpyObj('container', ['querySelector']);
|
||||
const closeReopenReportToggle = jasmine.createSpyObj('closeReopenReportToggle', ['initDroplab']);
|
||||
const dropdownTrigger = {};
|
||||
const dropdownList = {};
|
||||
const button = {};
|
||||
|
||||
spyOn(CloseReopenReportToggle.prototype, 'initDroplab');
|
||||
spyOn(document, 'querySelector').and.returnValue(container);
|
||||
spyOn(CloseReopenReportToggle, 'default').and.returnValue(closeReopenReportToggle);
|
||||
container.querySelector.and.returnValues(dropdownTrigger, dropdownList, button);
|
||||
|
||||
MergeRequest.initCloseReopenReport();
|
||||
|
@ -57,12 +56,7 @@ import * as CloseReopenReportToggle from '~/close_reopen_report_toggle';
|
|||
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-toggle');
|
||||
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-menu');
|
||||
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-button');
|
||||
expect(CloseReopenReportToggle.default).toHaveBeenCalledWith({
|
||||
dropdownTrigger,
|
||||
dropdownList,
|
||||
button,
|
||||
});
|
||||
expect(closeReopenReportToggle.initDroplab).toHaveBeenCalled();
|
||||
expect(CloseReopenReportToggle.prototype.initDroplab).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue