BigW Consortium Gitlab

Commit b61d0586 by Alfredo Sumaran

Merge branch 'add-element-extensions-tests' into 'master'

Added element extensions spec for .matches and .closest ## What does this MR do? Adds tests for `Element.prototype.matches` and `Element.prototype.closest`. ## Are there points in the code the reviewer needs to double check? ## Why was this MR needed? ## Screenshots (if relevant) ## Does this MR meet the acceptance criteria? - [ ] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added - [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [ ] API support added - Tests - [ ] Added for this feature/bug - [ ] All builds are passing - [ ] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html) - [ ] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [ ] Branch has no merge conflicts with `master` (if it does - rebase it please) - [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) ## What are the relevant issue numbers? See merge request !7755
parents 5fedc463 63e2d652
/*= require extensions/element */
(() => {
describe('Element extensions', 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();
});
});
});
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment