From 7187395ef13d8d84a145d1b5251882ebada3f7f2 Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Wed, 30 Aug 2017 07:48:55 +0000 Subject: Add filter by my reaction --- spec/javascripts/droplab/drop_down_spec.js | 15 +++++++++++++-- 1 file changed, 13 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 2bbcebeeac0..1ef494a00b8 100644 --- a/spec/javascripts/droplab/drop_down_spec.js +++ b/spec/javascripts/droplab/drop_down_spec.js @@ -351,14 +351,17 @@ describe('DropDown', function () { describe('render', function () { beforeEach(function () { - this.list = { querySelector: () => {} }; + this.list = { querySelector: () => {}, dispatchEvent: () => {} }; this.dropdown = { renderChildren: () => {}, list: this.list }; this.renderableList = {}; this.data = [0, 1]; + this.customEvent = {}; spyOn(this.dropdown, 'renderChildren').and.callFake(data => data); spyOn(this.list, 'querySelector').and.returnValue(this.renderableList); + spyOn(this.list, 'dispatchEvent'); spyOn(this.data, 'map').and.callThrough(); + spyOn(window, 'CustomEvent').and.returnValue(this.customEvent); DropDown.prototype.render.call(this.dropdown, this.data); }); @@ -375,6 +378,14 @@ describe('DropDown', function () { expect(this.renderableList.innerHTML).toBe('01'); }); + it('should call render.dl', function () { + expect(window.CustomEvent).toHaveBeenCalledWith('render.dl', jasmine.any(Object)); + }); + + it('should call dispatchEvent with the customEvent', function () { + expect(this.list.dispatchEvent).toHaveBeenCalledWith(this.customEvent); + }); + describe('if no data argument is passed', function () { beforeEach(function () { this.data.map.calls.reset(); @@ -394,7 +405,7 @@ describe('DropDown', function () { describe('if no dynamic list is present', function () { beforeEach(function () { - this.list = { querySelector: () => {} }; + this.list = { querySelector: () => {}, dispatchEvent: () => {} }; this.dropdown = { renderChildren: () => {}, list: this.list }; this.data = [0, 1]; -- cgit v1.2.1