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';
|
import ISetter from './droplab/plugins/input_setter';
|
||||||
|
|
||||||
// Todo: Remove this when fixing issue in input_setter plugin
|
// Todo: Remove this when fixing issue in input_setter plugin
|
||||||
|
@ -15,7 +15,7 @@ class CloseReopenReportToggle {
|
||||||
this.reopenItem = this.dropdownList.querySelector('.reopen-item');
|
this.reopenItem = this.dropdownList.querySelector('.reopen-item');
|
||||||
this.closeItem = this.dropdownList.querySelector('.close-item');
|
this.closeItem = this.dropdownList.querySelector('.close-item');
|
||||||
|
|
||||||
this.droplab = new DropLab.default();
|
this.droplab = new DropLab();
|
||||||
|
|
||||||
const config = this.setConfig();
|
const config = this.setConfig();
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import '~/lib/utils/text_utility';
|
||||||
import './flash';
|
import './flash';
|
||||||
import './task_list';
|
import './task_list';
|
||||||
import CreateMergeRequestDropdown from './create_merge_request_dropdown';
|
import CreateMergeRequestDropdown from './create_merge_request_dropdown';
|
||||||
import * as CloseReopenReportToggle from './close_reopen_report_toggle';
|
import CloseReopenReportToggle from './close_reopen_report_toggle';
|
||||||
|
|
||||||
class Issue {
|
class Issue {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -98,7 +98,7 @@ class Issue {
|
||||||
const dropdownList = container.querySelector('.js-issuable-close-menu');
|
const dropdownList = container.querySelector('.js-issuable-close-menu');
|
||||||
const button = container.querySelector('.js-issuable-close-button');
|
const button = container.querySelector('.js-issuable-close-button');
|
||||||
|
|
||||||
this.closeReopenReportToggle = new CloseReopenReportToggle.default({
|
this.closeReopenReportToggle = new CloseReopenReportToggle({
|
||||||
dropdownTrigger,
|
dropdownTrigger,
|
||||||
dropdownList,
|
dropdownList,
|
||||||
button,
|
button,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import 'vendor/jquery.waitforimages';
|
import 'vendor/jquery.waitforimages';
|
||||||
import './task_list';
|
import './task_list';
|
||||||
import './merge_request_tabs';
|
import './merge_request_tabs';
|
||||||
import * as CloseReopenReportToggle from './close_reopen_report_toggle';
|
import CloseReopenReportToggle from './close_reopen_report_toggle';
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
this.MergeRequest = (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 dropdownList = container.querySelector('.js-issuable-close-menu');
|
||||||
const button = container.querySelector('.js-issuable-close-button');
|
const button = container.querySelector('.js-issuable-close-button');
|
||||||
|
|
||||||
const closeReopenReportToggle = new CloseReopenReportToggle.default({
|
const closeReopenReportToggle = new CloseReopenReportToggle({
|
||||||
dropdownTrigger,
|
dropdownTrigger,
|
||||||
dropdownList,
|
dropdownList,
|
||||||
button,
|
button,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import CloseReopenReportToggle from '~/close_reopen_report_toggle';
|
import CloseReopenReportToggle from '~/close_reopen_report_toggle';
|
||||||
import * as DropLab from '~/droplab/drop_lab';
|
import DropLab from '~/droplab/drop_lab';
|
||||||
|
|
||||||
describe('CloseReopenReportToggle', () => {
|
describe('CloseReopenReportToggle', () => {
|
||||||
describe('class constructor', () => {
|
describe('class constructor', () => {
|
||||||
|
@ -32,7 +32,6 @@ describe('CloseReopenReportToggle', () => {
|
||||||
describe('initDroplab', () => {
|
describe('initDroplab', () => {
|
||||||
let closeReopenReportToggle;
|
let closeReopenReportToggle;
|
||||||
const dropdownList = jasmine.createSpyObj('dropdownList', ['querySelector']);
|
const dropdownList = jasmine.createSpyObj('dropdownList', ['querySelector']);
|
||||||
const droplab = jasmine.createSpyObj('droplab', ['init']);
|
|
||||||
const dropdownTrigger = {};
|
const dropdownTrigger = {};
|
||||||
const button = {};
|
const button = {};
|
||||||
const reopenItem = {};
|
const reopenItem = {};
|
||||||
|
@ -40,7 +39,7 @@ describe('CloseReopenReportToggle', () => {
|
||||||
const config = {};
|
const config = {};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(DropLab, 'default').and.returnValue(droplab);
|
spyOn(DropLab.prototype, 'init');
|
||||||
dropdownList.querySelector.and.returnValues(reopenItem, closeItem);
|
dropdownList.querySelector.and.returnValues(reopenItem, closeItem);
|
||||||
|
|
||||||
closeReopenReportToggle = new CloseReopenReportToggle({
|
closeReopenReportToggle = new CloseReopenReportToggle({
|
||||||
|
@ -61,17 +60,16 @@ describe('CloseReopenReportToggle', () => {
|
||||||
expect(closeReopenReportToggle.closeItem).toBe(closeItem);
|
expect(closeReopenReportToggle.closeItem).toBe(closeItem);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('instantiates DropLab and set .droplab', () => {
|
it('sets .droplab', () => {
|
||||||
expect(DropLab.default).toHaveBeenCalled();
|
expect(closeReopenReportToggle.droplab).toEqual(jasmine.any(Object));
|
||||||
expect(closeReopenReportToggle.droplab).toBe(droplab);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls .setConfig', () => {
|
it('calls .setConfig', () => {
|
||||||
expect(closeReopenReportToggle.setConfig).toHaveBeenCalled();
|
expect(closeReopenReportToggle.setConfig).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls .droplab.init', () => {
|
it('calls droplab.init', () => {
|
||||||
expect(droplab.init).toHaveBeenCalledWith(
|
expect(DropLab.prototype.init).toHaveBeenCalledWith(
|
||||||
dropdownTrigger,
|
dropdownTrigger,
|
||||||
dropdownList,
|
dropdownList,
|
||||||
jasmine.any(Array),
|
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 */
|
/* 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 Issue from '~/issue';
|
||||||
import * as CloseReopenReportToggle from '~/close_reopen_report_toggle';
|
import CloseReopenReportToggle from '~/close_reopen_report_toggle';
|
||||||
import '~/lib/utils/text_utility';
|
import '~/lib/utils/text_utility';
|
||||||
|
|
||||||
describe('Issue', function() {
|
describe('Issue', function() {
|
||||||
|
@ -208,15 +208,14 @@ describe('Issue', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('initCloseReopenReport', () => {
|
describe('initCloseReopenReport', () => {
|
||||||
it('inits a new CloseReopenReportToggle instance and calls .initDroplab', () => {
|
it('calls .initDroplab', () => {
|
||||||
const container = jasmine.createSpyObj('container', ['querySelector']);
|
const container = jasmine.createSpyObj('container', ['querySelector']);
|
||||||
const closeReopenReportToggle = jasmine.createSpyObj('closeReopenReportToggle', ['initDroplab']);
|
|
||||||
const dropdownTrigger = {};
|
const dropdownTrigger = {};
|
||||||
const dropdownList = {};
|
const dropdownList = {};
|
||||||
const button = {};
|
const button = {};
|
||||||
|
|
||||||
spyOn(document, 'querySelector').and.returnValue(container);
|
spyOn(document, 'querySelector').and.returnValue(container);
|
||||||
spyOn(CloseReopenReportToggle, 'default').and.returnValue(closeReopenReportToggle);
|
spyOn(CloseReopenReportToggle.prototype, 'initDroplab');
|
||||||
container.querySelector.and.returnValues(dropdownTrigger, dropdownList, button);
|
container.querySelector.and.returnValues(dropdownTrigger, dropdownList, button);
|
||||||
|
|
||||||
Issue.prototype.initCloseReopenReport();
|
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-toggle');
|
||||||
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-menu');
|
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-menu');
|
||||||
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-button');
|
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-button');
|
||||||
expect(CloseReopenReportToggle.default).toHaveBeenCalledWith({
|
expect(CloseReopenReportToggle.prototype.initDroplab).toHaveBeenCalled();
|
||||||
dropdownTrigger,
|
|
||||||
dropdownList,
|
|
||||||
button,
|
|
||||||
});
|
|
||||||
expect(closeReopenReportToggle.initDroplab).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/* global MergeRequest */
|
/* global MergeRequest */
|
||||||
|
|
||||||
import '~/merge_request';
|
import '~/merge_request';
|
||||||
import * as CloseReopenReportToggle from '~/close_reopen_report_toggle';
|
import CloseReopenReportToggle from '~/close_reopen_report_toggle';
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
describe('MergeRequest', function() {
|
describe('MergeRequest', function() {
|
||||||
|
@ -40,15 +40,14 @@ import * as CloseReopenReportToggle from '~/close_reopen_report_toggle';
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('initCloseReopenReport', () => {
|
describe('initCloseReopenReport', () => {
|
||||||
it('inits a new CloseReopenReportToggle instance and calls .initDroplab', () => {
|
it('calls .initDroplab', () => {
|
||||||
const container = jasmine.createSpyObj('container', ['querySelector']);
|
const container = jasmine.createSpyObj('container', ['querySelector']);
|
||||||
const closeReopenReportToggle = jasmine.createSpyObj('closeReopenReportToggle', ['initDroplab']);
|
|
||||||
const dropdownTrigger = {};
|
const dropdownTrigger = {};
|
||||||
const dropdownList = {};
|
const dropdownList = {};
|
||||||
const button = {};
|
const button = {};
|
||||||
|
|
||||||
|
spyOn(CloseReopenReportToggle.prototype, 'initDroplab');
|
||||||
spyOn(document, 'querySelector').and.returnValue(container);
|
spyOn(document, 'querySelector').and.returnValue(container);
|
||||||
spyOn(CloseReopenReportToggle, 'default').and.returnValue(closeReopenReportToggle);
|
|
||||||
container.querySelector.and.returnValues(dropdownTrigger, dropdownList, button);
|
container.querySelector.and.returnValues(dropdownTrigger, dropdownList, button);
|
||||||
|
|
||||||
MergeRequest.initCloseReopenReport();
|
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-toggle');
|
||||||
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-menu');
|
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-menu');
|
||||||
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-button');
|
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-button');
|
||||||
expect(CloseReopenReportToggle.default).toHaveBeenCalledWith({
|
expect(CloseReopenReportToggle.prototype.initDroplab).toHaveBeenCalled();
|
||||||
dropdownTrigger,
|
|
||||||
dropdownList,
|
|
||||||
button,
|
|
||||||
});
|
|
||||||
expect(closeReopenReportToggle.initDroplab).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue