From 907b754173ed4185574c38ded0a173360d073085 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Fri, 7 Apr 2017 02:50:10 +0100 Subject: Fixed bugs and added tests --- spec/javascripts/droplab/drop_down_spec.js | 17 ++++++++++++++++- spec/javascripts/droplab/plugins/input_setter_spec.js | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'spec/javascripts/droplab') diff --git a/spec/javascripts/droplab/drop_down_spec.js b/spec/javascripts/droplab/drop_down_spec.js index bbf953658c8..802e2435672 100644 --- a/spec/javascripts/droplab/drop_down_spec.js +++ b/spec/javascripts/droplab/drop_down_spec.js @@ -130,7 +130,7 @@ describe('DropDown', function () { beforeEach(function () { this.list = { dispatchEvent: () => {} }; this.dropdown = { hide: () => {}, list: this.list, addSelectedClass: () => {} }; - this.event = { preventDefault: () => {}, target: 'target' }; + this.event = { preventDefault: () => {}, target: {} }; this.customEvent = {}; this.closestElement = {}; @@ -168,6 +168,21 @@ describe('DropDown', function () { expect(this.list.dispatchEvent).toHaveBeenCalledWith(this.customEvent); }); + describe('if the target is a UL element', function () { + beforeEach(function () { + this.event = { preventDefault: () => {}, target: { tagName: 'UL' } }; + + spyOn(this.event, 'preventDefault'); + utils.closest.calls.reset(); + + DropDown.prototype.clickEvent.call(this.dropdown, this.event); + }); + + it('should return immediately', function () { + expect(utils.closest).not.toHaveBeenCalled(); + }); + }); + describe('if no selected element exists', function () { beforeEach(function () { this.event.preventDefault.calls.reset(); diff --git a/spec/javascripts/droplab/plugins/input_setter_spec.js b/spec/javascripts/droplab/plugins/input_setter_spec.js index 412d1054385..bd625f4ae80 100644 --- a/spec/javascripts/droplab/plugins/input_setter_spec.js +++ b/spec/javascripts/droplab/plugins/input_setter_spec.js @@ -2,7 +2,7 @@ import InputSetter from '~/droplab/plugins/input_setter'; -fdescribe('InputSetter', function () { +describe('InputSetter', function () { describe('init', function () { beforeEach(function () { this.config = { InputSetter: {} }; -- cgit v1.2.3