summaryrefslogtreecommitdiff
path: root/spec/javascripts/comment_type_toggle_spec.js
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-07 14:09:15 +0100
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-07 14:09:15 +0100
commit18e2388de19f47093cb3192f4b8dbabdd9c3bfad (patch)
treed7960767b781d5a50da2a0bfbf889bcc8ef35644 /spec/javascripts/comment_type_toggle_spec.js
parent2f22890d4223c0b524ee1f27e222a24a8f0c9a87 (diff)
downloadgitlab-ce-18e2388de19f47093cb3192f4b8dbabdd9c3bfad.tar.gz
Fixed issue button state bug
Diffstat (limited to 'spec/javascripts/comment_type_toggle_spec.js')
-rw-r--r--spec/javascripts/comment_type_toggle_spec.js93
1 files changed, 56 insertions, 37 deletions
diff --git a/spec/javascripts/comment_type_toggle_spec.js b/spec/javascripts/comment_type_toggle_spec.js
index 818c1635710..9a341ebd811 100644
--- a/spec/javascripts/comment_type_toggle_spec.js
+++ b/spec/javascripts/comment_type_toggle_spec.js
@@ -11,13 +11,13 @@ describe('CommentTypeToggle', function () {
this.submitButton = {};
this.closeButton = {};
- this.commentTypeToggle = new CommentTypeToggle(
- this.dropdownTrigger,
- this.dropdownList,
- this.noteTypeInput,
- this.submitButton,
- this.closeButton,
- );
+ this.commentTypeToggle = new CommentTypeToggle({
+ dropdownTrigger: this.dropdownTrigger,
+ dropdownList: this.dropdownList,
+ noteTypeInput: this.noteTypeInput,
+ submitButton: this.submitButton,
+ closeButton: this.closeButton,
+ });
});
it('should set .dropdownTrigger', function () {
@@ -39,6 +39,10 @@ describe('CommentTypeToggle', function () {
it('should set .closeButton', function () {
expect(this.commentTypeToggle.closeButton).toBe(this.closeButton);
});
+
+ it('should set .reopenButton', function () {
+ expect(this.commentTypeToggle.reopenButton).toBe(this.reopenButton);
+ });
});
describe('initDroplab', function () {
@@ -49,13 +53,16 @@ describe('CommentTypeToggle', function () {
noteTypeInput: {},
submitButton: {},
closeButton: {},
+ setConfig: () => {},
};
+ this.config = {};
this.droplab = jasmine.createSpyObj('droplab', ['init']);
spyOn(dropLabSrc, 'default').and.returnValue(this.droplab);
+ spyOn(this.commentTypeToggle, 'setConfig').and.returnValue(this.config);
- this.initDroplab = CommentTypeToggle.prototype.initDroplab.call(this.commentTypeToggle);
+ CommentTypeToggle.prototype.initDroplab.call(this.commentTypeToggle);
});
it('should instantiate a DropLab instance', function () {
@@ -66,58 +73,70 @@ describe('CommentTypeToggle', function () {
expect(this.commentTypeToggle.droplab).toBe(this.droplab);
});
+ it('should call .setConfig', function () {
+ expect(this.commentTypeToggle.setConfig).toHaveBeenCalled();
+ });
+
it('should call DropLab.prototype.init', function () {
expect(this.droplab.init).toHaveBeenCalledWith(
this.commentTypeToggle.dropdownTrigger,
this.commentTypeToggle.dropdownList,
[InputSetter],
- {
+ this.config,
+ );
+ });
+ });
+
+ describe('setConfig', function () {
+ describe('if no .closeButton is provided', function () {
+ beforeEach(function () {
+ this.commentTypeToggle = {
+ dropdownTrigger: {},
+ dropdownList: {},
+ noteTypeInput: {},
+ submitButton: {},
+ reopenButton: {},
+ };
+
+ this.setConfig = CommentTypeToggle.prototype.setConfig.call(this.commentTypeToggle);
+ });
+
+ it('should not add .closeButton or .reopenButton related InputSetter config', function () {
+ expect(this.setConfig).toEqual({
InputSetter: [{
input: this.commentTypeToggle.noteTypeInput,
valueAttribute: 'data-value',
}, {
input: this.commentTypeToggle.submitButton,
- valueAttribute: 'data-button-text',
- },
- {
- input: this.commentTypeToggle.closeButton,
- valueAttribute: 'data-secondary-button-text',
- }, {
- input: this.commentTypeToggle.closeButton,
- valueAttribute: 'data-secondary-button-text',
- inputAttribute: 'data-alternative-text',
+ valueAttribute: 'data-submit-text',
}],
- },
- );
+ });
+ });
});
- describe('if no .closeButton is provided', function () {
+ describe('if no .reopenButton is provided', function () {
beforeEach(function () {
this.commentTypeToggle = {
dropdownTrigger: {},
dropdownList: {},
noteTypeInput: {},
submitButton: {},
+ closeButton: {},
};
- this.initDroplab = CommentTypeToggle.prototype.initDroplab.call(this.commentTypeToggle);
+ this.setConfig = CommentTypeToggle.prototype.setConfig.call(this.commentTypeToggle);
});
- it('should not add .closeButton related InputSetter config', function () {
- expect(this.droplab.init).toHaveBeenCalledWith(
- this.commentTypeToggle.dropdownTrigger,
- this.commentTypeToggle.dropdownList,
- [InputSetter],
- {
- InputSetter: [{
- input: this.commentTypeToggle.noteTypeInput,
- valueAttribute: 'data-value',
- }, {
- input: this.commentTypeToggle.submitButton,
- valueAttribute: 'data-button-text',
- }],
- },
- );
+ it('should not add .closeButton or .reopenButton related InputSetter config', function () {
+ expect(this.setConfig).toEqual({
+ InputSetter: [{
+ input: this.commentTypeToggle.noteTypeInput,
+ valueAttribute: 'data-value',
+ }, {
+ input: this.commentTypeToggle.submitButton,
+ valueAttribute: 'data-submit-text',
+ }],
+ });
});
});
});