Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bennett <lukeeeebennettplus@gmail.com>2016-07-28 19:32:43 +0300
committerLuke Bennett <lukeeeebennettplus@gmail.com>2016-08-18 20:17:56 +0300
commit49c7ca2a27639809dd84975d7595787ab5f60647 (patch)
tree642528560e1accae7e689d3cc667f786af82fe5a /spec/javascripts
parentf91fd18f25626dc3e76c9aefef2841f685fab26c (diff)
Fixed spec and improved formatting
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/gl_dropdown_spec.js.es653
1 files changed, 25 insertions, 28 deletions
diff --git a/spec/javascripts/gl_dropdown_spec.js.es6 b/spec/javascripts/gl_dropdown_spec.js.es6
index 2dda566beb6..4ed194f5179 100644
--- a/spec/javascripts/gl_dropdown_spec.js.es6
+++ b/spec/javascripts/gl_dropdown_spec.js.es6
@@ -16,12 +16,13 @@
ESC: 27
};
- var navigateWithKeys = function navigateWithKeys(direction, steps, cb, i) {
+ let navigateWithKeys = function navigateWithKeys(direction, steps, cb, i) {
i = i || 0;
+ if (!i) direction = direction.toUpperCase();
$('body').trigger({
type: 'keydown',
- which: ARROW_KEYS[direction.toUpperCase()],
- keyCode: ARROW_KEYS[direction.toUpperCase()]
+ which: ARROW_KEYS[direction],
+ keyCode: ARROW_KEYS[direction]
});
i++;
if (i <= steps) {
@@ -31,35 +32,31 @@
}
};
- var initDropdown = function initDropdown() {
- this.dropdownContainerElement = $('.dropdown.inline');
- this.dropdownMenuElement = $('.dropdown-menu', this.dropdownContainerElement);
- this.projectsData = fixture.load('projects.json')[0];
- this.dropdownButtonElement = $('#js-project-dropdown', this.dropdownContainerElement).glDropdown({
- selectable: true,
- data: this.projectsData,
- text: (project) => {
- (project.name_with_namespace || project.name)
- },
- id: (project) => {
- project.id
- }
- });
- };
-
describe('Dropdown', function describeDropdown() {
fixture.preload('gl_dropdown.html');
fixture.preload('projects.json');
- function beforeEach() {
+ beforeEach(() => {
fixture.load('gl_dropdown.html');
- initDropdown.call(this);
- }
+ this.dropdownContainerElement = $('.dropdown.inline');
+ this.dropdownMenuElement = $('.dropdown-menu', this.dropdownContainerElement);
+ this.projectsData = fixture.load('projects.json')[0];
+ this.dropdownButtonElement = $('#js-project-dropdown', this.dropdownContainerElement).glDropdown({
+ selectable: true,
+ data: this.projectsData,
+ text: (project) => {
+ (project.name_with_namespace || project.name)
+ },
+ id: (project) => {
+ project.id
+ }
+ });
+ });
- function afterEach() {
+ afterEach(() => {
$('body').unbind('keydown');
this.dropdownContainerElement.unbind('keyup');
- }
+ });
it('should open on click', () => {
expect(this.dropdownContainerElement).not.toHaveClass('open');
@@ -67,10 +64,10 @@
expect(this.dropdownContainerElement).toHaveClass('open');
});
- describe('that is open', function describeThatIsOpen() {
- function beforeEach() {
+ describe('that is open', () => {
+ beforeEach(() => {
this.dropdownButtonElement.click();
- }
+ });
it('should select a following item on DOWN keypress', () => {
expect($(FOCUSED_ITEM_SELECTOR, this.dropdownMenuElement).length).toBe(0);
@@ -119,4 +116,4 @@
});
});
});
-})(window);
+})();