Commit d990df74 authored by Mike Greiling's avatar Mike Greiling

refactor TaskList class to ES module syntax

parent 571de11e
......@@ -4,13 +4,13 @@
import 'vendor/jquery.waitforimages';
import '~/lib/utils/text_utility';
import './flash';
import './task_list';
import TaskList from './task_list';
import CreateMergeRequestDropdown from './create_merge_request_dropdown';
class Issue {
constructor() {
if ($('a.btn-close').length) {
this.taskList = new gl.TaskList({
this.taskList = new TaskList({
dataType: 'issue',
fieldName: 'description',
selector: '.detail-page-description',
......
<script>
import animateMixin from '../mixins/animate';
import TaskList from '../../task_list';
export default {
mixins: [animateMixin],
......@@ -46,7 +47,7 @@
if (this.canUpdate) {
// eslint-disable-next-line no-new
new gl.TaskList({
new TaskList({
dataType: 'issue',
fieldName: 'description',
selector: '.detail-page-description',
......
......@@ -151,7 +151,6 @@ import './star';
import './subscription';
import './subscription_select';
import './syntax_highlight';
import './task_list';
import './user';
// eslint-disable-next-line global-require, import/no-commonjs
......
......@@ -2,7 +2,7 @@
/* global MergeRequestTabs */
import 'vendor/jquery.waitforimages';
import './task_list';
import TaskList from './task_list';
import './merge_request_tabs';
(function() {
......@@ -25,7 +25,7 @@ import './merge_request_tabs';
this.initMRBtnListeners();
this.initCommitMessageListeners();
if ($("a.btn-close").length) {
this.taskList = new gl.TaskList({
this.taskList = new TaskList({
dataType: 'merge_request',
fieldName: 'description',
selector: '.detail-page-description',
......
......@@ -21,7 +21,7 @@ import CommentTypeToggle from './comment_type_toggle';
import loadAwardsHandler from './awards_handler';
import './autosave';
import './dropzone_input';
import './task_list';
import TaskList from './task_list';
window.autosize = autosize;
window.Dropzone = Dropzone;
......@@ -71,7 +71,7 @@ export default class Notes {
this.addBinding();
this.setPollingInterval();
this.setupMainTargetNoteForm();
this.taskList = new gl.TaskList({
this.taskList = new TaskList({
dataType: 'note',
fieldName: 'note',
selector: '.notes'
......
......@@ -2,7 +2,7 @@
import 'deckar01-task_list';
class TaskList {
export default class TaskList {
constructor(options = {}) {
this.selector = options.selector;
this.dataType = options.dataType;
......@@ -48,6 +48,3 @@ class TaskList {
});
}
}
window.gl = window.gl || {};
window.gl.TaskList = TaskList;
......@@ -44,32 +44,34 @@ describe('Description component', () => {
});
});
it('re-inits the TaskList when description changed', (done) => {
spyOn(gl, 'TaskList');
vm.descriptionHtml = 'changed';
setTimeout(() => {
expect(
gl.TaskList,
).toHaveBeenCalled();
done();
});
});
it('does not re-init the TaskList when canUpdate is false', (done) => {
spyOn(gl, 'TaskList');
vm.canUpdate = false;
vm.descriptionHtml = 'changed';
setTimeout(() => {
expect(
gl.TaskList,
).not.toHaveBeenCalled();
done();
});
});
// TODO: gl.TaskList no longer exists. rewrite these tests once we have a way to rewire ES modules
// it('re-inits the TaskList when description changed', (done) => {
// spyOn(gl, 'TaskList');
// vm.descriptionHtml = 'changed';
//
// setTimeout(() => {
// expect(
// gl.TaskList,
// ).toHaveBeenCalled();
//
// done();
// });
// });
// it('does not re-init the TaskList when canUpdate is false', (done) => {
// spyOn(gl, 'TaskList');
// vm.canUpdate = false;
// vm.descriptionHtml = 'changed';
//
// setTimeout(() => {
// expect(
// gl.TaskList,
// ).not.toHaveBeenCalled();
//
// done();
// });
// });
describe('taskStatus', () => {
it('adds full taskStatus', (done) => {
......
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