diff options
author | Mike Greiling <mgreiling@gitlab.com> | 2017-03-13 21:48:32 +0000 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2017-03-13 21:48:32 +0000 |
commit | 29e0cb4b91b3800ef4974c54b8473e6e4fb28e16 (patch) | |
tree | 3b0f9d9e221755caa71be35a34f2fbc9072ebf0e /spec/javascripts/polyfills | |
parent | 88206d67c38e87685bbacc14cfd60ee9dc42ac7f (diff) | |
download | gitlab-ce-29e0cb4b91b3800ef4974c54b8473e6e4fb28e16.tar.gz |
Organize our polyfills and standardize on core-js
Diffstat (limited to 'spec/javascripts/polyfills')
-rw-r--r-- | spec/javascripts/polyfills/element_spec.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/javascripts/polyfills/element_spec.js b/spec/javascripts/polyfills/element_spec.js new file mode 100644 index 00000000000..ecaaf1907ea --- /dev/null +++ b/spec/javascripts/polyfills/element_spec.js @@ -0,0 +1,36 @@ +import '~/commons/polyfills/element'; + +describe('Element polyfills', function () { + beforeEach(() => { + this.element = document.createElement('ul'); + }); + + describe('matches', () => { + it('returns true if element matches the selector', () => { + expect(this.element.matches('ul')).toBeTruthy(); + }); + + it("returns false if element doesn't match the selector", () => { + expect(this.element.matches('.not-an-element')).toBeFalsy(); + }); + }); + + describe('closest', () => { + beforeEach(() => { + this.childElement = document.createElement('li'); + this.element.appendChild(this.childElement); + }); + + it('returns the closest parent that matches the selector', () => { + expect(this.childElement.closest('ul').toString()).toBe(this.element.toString()); + }); + + it('returns itself if it matches the selector', () => { + expect(this.childElement.closest('li').toString()).toBe(this.childElement.toString()); + }); + + it('returns undefined if nothing matches the selector', () => { + expect(this.childElement.closest('.no-an-element')).toBeFalsy(); + }); + }); +}); |