Skip to content

Commit

Permalink
feat(accordion): toggle via keyboard (#2085)
Browse files Browse the repository at this point in the history
  • Loading branch information
armoucar authored and yggg committed Nov 21, 2019
1 parent 5945d6a commit f8a1b32
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 22 additions & 1 deletion e2e/accordion.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { browser, element, by } from 'protractor';
import { browser, element, by, Key } from 'protractor';

import { hasClass } from './e2e-helper';

Expand Down Expand Up @@ -42,4 +42,25 @@ describe('accordion', () => {
hasClass(element(by.css('nb-accordion > nb-accordion-item:nth-child(3)')), 'expanded'),
).toBeTruthy('second is expanded');
});

describe('a11y', () => {

it('should be interactable through keyboard', () => {
expect(
hasClass(
element(by.css('nb-accordion > nb-accordion-item:nth-child(3)')) , 'expanded',
),
).toBeTruthy();

return element(by.css('nb-accordion > nb-accordion-item:nth-child(3) > nb-accordion-item-header'))
.sendKeys(Key.ENTER)
.then(() => {
expect(
hasClass(
element(by.css('nb-accordion > nb-accordion-item:nth-child(3)')), 'collapsed',
),
).toBeTruthy('nb-accordion-item is collapsed');
})
})
})
});
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export class NbAccordionItemHeaderComponent implements OnInit, OnDestroy {
}

@HostListener('click')
@HostListener('keydown.space')
@HostListener('keydown.enter')
toggle() {
this.accordionItem.toggle();
}
Expand Down

0 comments on commit f8a1b32

Please sign in to comment.