From 67c2e741195083b9c9d5d5f741c7909d22bc988b Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Thu, 8 Dec 2016 17:24:30 +0000 Subject: [PATCH 1/3] Adds tests for Custom Event polyfill Update changelog with MR ID --- .../24927-custom-event-polyfill-test.yml | 4 ++ .../utils/custom_event_polyfill_spec.js.es6 | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 changelogs/unreleased/24927-custom-event-polyfill-test.yml create mode 100644 spec/javascripts/lib/utils/custom_event_polyfill_spec.js.es6 diff --git a/changelogs/unreleased/24927-custom-event-polyfill-test.yml b/changelogs/unreleased/24927-custom-event-polyfill-test.yml new file mode 100644 index 00000000000..879c28a951e --- /dev/null +++ b/changelogs/unreleased/24927-custom-event-polyfill-test.yml @@ -0,0 +1,4 @@ +--- +title: Adds tests for custom event polyfill +merge_request: 7996 +author: diff --git a/spec/javascripts/lib/utils/custom_event_polyfill_spec.js.es6 b/spec/javascripts/lib/utils/custom_event_polyfill_spec.js.es6 new file mode 100644 index 00000000000..ad51367bb32 --- /dev/null +++ b/spec/javascripts/lib/utils/custom_event_polyfill_spec.js.es6 @@ -0,0 +1,43 @@ +//= require lib/utils/custom_event_polyfill + +describe('Custom Event Polyfill', () => { + it('should be defined', () => { + expect(window.CustomEvent).toBeDefined(); + }); + + it('should create a `CustomEvent` instance', () => { + const e = new window.CustomEvent('foo'); + + expect(e.type).toEqual('foo'); + expect(e.bubbles).toBe(false); + expect(e.cancelable).toBe(false); + expect(e.detail).toBe(null); + }); + + it('should create a `CustomEvent` instance with a `details` object', () => { + const e = new window.CustomEvent('bar', { detail: { foo: 'bar' } }); + + expect(e.type).toEqual('bar'); + expect(e.bubbles).toBe(false); + expect(e.cancelable).toBe(false); + expect(e.detail.foo).toEqual('bar'); + }); + + it('should create a `CustomEvent` instance with a `bubbles` boolean', () => { + const e = new window.CustomEvent('bar', { bubbles: true }); + + expect(e.type).toEqual('bar'); + expect(e.bubbles).toBe(true); + expect(e.cancelable).toBe(false); + expect(e.detail).toBe(null); + }); + + it('should create a `CustomEvent` instance with a `cancelable` boolean', () => { + const e = new window.CustomEvent('bar', { cancelable: true }); + + expect(e.type).toEqual('bar'); + expect(e.bubbles).toBe(false); + expect(e.cancelable).toBe(true); + expect(e.detail).toBe(null); + }); +}); From 383e6b552e4b3ae9b2fdf9c1401dca2aef8e98e7 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Fri, 9 Dec 2016 12:13:54 +0000 Subject: [PATCH 2/3] Fix broken test --- .../javascripts/lib/utils/custom_event_polyfill_spec.js.es6 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/javascripts/lib/utils/custom_event_polyfill_spec.js.es6 b/spec/javascripts/lib/utils/custom_event_polyfill_spec.js.es6 index ad51367bb32..1c5bf8887f8 100644 --- a/spec/javascripts/lib/utils/custom_event_polyfill_spec.js.es6 +++ b/spec/javascripts/lib/utils/custom_event_polyfill_spec.js.es6 @@ -11,7 +11,7 @@ describe('Custom Event Polyfill', () => { expect(e.type).toEqual('foo'); expect(e.bubbles).toBe(false); expect(e.cancelable).toBe(false); - expect(e.detail).toBe(null); + expect(e.detail).toBe(undefined); }); it('should create a `CustomEvent` instance with a `details` object', () => { @@ -29,7 +29,7 @@ describe('Custom Event Polyfill', () => { expect(e.type).toEqual('bar'); expect(e.bubbles).toBe(true); expect(e.cancelable).toBe(false); - expect(e.detail).toBe(null); + expect(e.detail).toBe(undefined); }); it('should create a `CustomEvent` instance with a `cancelable` boolean', () => { @@ -38,6 +38,6 @@ describe('Custom Event Polyfill', () => { expect(e.type).toEqual('bar'); expect(e.bubbles).toBe(false); expect(e.cancelable).toBe(true); - expect(e.detail).toBe(null); + expect(e.detail).toBe(undefined); }); }); From 7caab6c2ae6e8063472a224d846f9157c07dc53f Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Tue, 13 Dec 2016 11:04:43 +0000 Subject: [PATCH 3/3] Fix broken test in chrome --- .../javascripts/lib/utils/custom_event_polyfill_spec.js.es6 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/javascripts/lib/utils/custom_event_polyfill_spec.js.es6 b/spec/javascripts/lib/utils/custom_event_polyfill_spec.js.es6 index 1c5bf8887f8..3645dd70c55 100644 --- a/spec/javascripts/lib/utils/custom_event_polyfill_spec.js.es6 +++ b/spec/javascripts/lib/utils/custom_event_polyfill_spec.js.es6 @@ -11,7 +11,7 @@ describe('Custom Event Polyfill', () => { expect(e.type).toEqual('foo'); expect(e.bubbles).toBe(false); expect(e.cancelable).toBe(false); - expect(e.detail).toBe(undefined); + expect(e.detail).toBeFalsy(); }); it('should create a `CustomEvent` instance with a `details` object', () => { @@ -29,7 +29,7 @@ describe('Custom Event Polyfill', () => { expect(e.type).toEqual('bar'); expect(e.bubbles).toBe(true); expect(e.cancelable).toBe(false); - expect(e.detail).toBe(undefined); + expect(e.detail).toBeFalsy(); }); it('should create a `CustomEvent` instance with a `cancelable` boolean', () => { @@ -38,6 +38,6 @@ describe('Custom Event Polyfill', () => { expect(e.type).toEqual('bar'); expect(e.bubbles).toBe(false); expect(e.cancelable).toBe(true); - expect(e.detail).toBe(undefined); + expect(e.detail).toBeFalsy(); }); });