Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
63e2d652
Commit
63e2d652
authored
Nov 25, 2016
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added element extensions spec for .matches and .closest
parent
141593fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
spec/javascripts/extensions/element_spec.js.es6
spec/javascripts/extensions/element_spec.js.es6
+38
-0
No files found.
spec/javascripts/extensions/element_spec.js.es6
0 → 100644
View file @
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();
});
});
});
})();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment