summaryrefslogtreecommitdiff
path: root/spec/javascripts/comment_type_toggle_spec.js
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-05 16:58:01 +0100
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-05 18:34:13 +0100
commit5e3fa0255341fea8d0842453ff034c3bf5f00ba2 (patch)
tree44f08bdd9599641786b7fe2183715efa72af2cef /spec/javascripts/comment_type_toggle_spec.js
parent2b92f91038ad24a2ff3a6607f826cd8e518d8aa2 (diff)
downloadgitlab-ce-5e3fa0255341fea8d0842453ff034c3bf5f00ba2.tar.gz
Added resolvable discussion frontend
Diffstat (limited to 'spec/javascripts/comment_type_toggle_spec.js')
-rw-r--r--spec/javascripts/comment_type_toggle_spec.js79
1 files changed, 79 insertions, 0 deletions
diff --git a/spec/javascripts/comment_type_toggle_spec.js b/spec/javascripts/comment_type_toggle_spec.js
new file mode 100644
index 00000000000..d68c221f0ea
--- /dev/null
+++ b/spec/javascripts/comment_type_toggle_spec.js
@@ -0,0 +1,79 @@
+import CommentTypeToggle from '~/comment_type_toggle';
+import DropLab from '@gitlab-org/droplab';
+import InputSetter from '@gitlab-org/droplab/dist/plugins/InputSetter';
+
+describe('CommentTypeToggle', function () {
+ describe('class constructor', function () {
+ beforeEach(function () {
+ this.trigger = {};
+ this.list = {};
+ this.input = {};
+ this.button = {};
+
+ this.commentTypeToggle = new CommentTypeToggle(
+ this.trigger,
+ this.list,
+ this.input,
+ this.button,
+ );
+ });
+
+ it('should set .trigger', function () {
+ expect(this.commentTypeToggle.trigger).toBe(this.trigger);
+ });
+
+ it('should set .list', function () {
+ expect(this.commentTypeToggle.list).toBe(this.list);
+ });
+
+ it('should set .input', function () {
+ expect(this.commentTypeToggle.input).toBe(this.input);
+ });
+
+ it('should set .button', function () {
+ expect(this.commentTypeToggle.button).toBe(this.button);
+ });
+ });
+
+ describe('initDroplab', function () {
+ beforeEach(function () {
+ this.commentTypeToggle = {
+ trigger: {},
+ list: {},
+ input: {},
+ button: {},
+ };
+
+ this.droplab = jasmine.createSpyObj('droplab', ['addHook']);
+
+ spyOn(window, 'DropLab').and.returnValue(this.droplab);
+
+ this.initDroplab = CommentTypeToggle.prototype.initDroplab.call(this.commentTypeToggle);
+ });
+
+ it('should instantiate a DropLab instance', function () {
+ expect(window.DropLab).toHaveBeenCalled();
+ });
+
+ it('should set .droplab', function () {
+ expect(this.commentTypeToggle.droplab).toBe(this.droplab);
+ });
+
+ it('should call DropLab.prototype.addHook', function () {
+ expect(this.droplab.addHook).toHaveBeenCalledWith(
+ this.commentTypeToggle.trigger,
+ this.commentTypeToggle.list,
+ [InputSetter],
+ {
+ InputSetter: [{
+ input: this.commentTypeToggle.input,
+ valueAttribute: 'data-value',
+ }, {
+ input: this.commentTypeToggle.button,
+ valueAttribute: 'data-button-text',
+ }],
+ },
+ );
+ });
+ });
+});