Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit c979062

Browse files
committed
adding tests for carousel item behavior
1 parent 757ce6d commit c979062

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

packages/accessibility/src/behaviors/Carousel/carouselItemBehavior.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import { Accessibility } from '../../types'
22
import * as keyboardKey from 'keyboard-key'
33

44
/**
5+
* @description
6+
* Adds attribute 'tabIndex=0' to 'root' slot if 'active' property and 'navigation' property is true. Sets the attribute to '-1' otherwise.
7+
*
58
* @specification
69
* Adds attribute 'role=tabpanel' to 'root' slot if 'navigation' property is true. Sets the attribute to 'group' otherwise.
710
* Adds attribute 'aria-hidden=false' to 'root' slot if 'active' property is true. Sets the attribute to 'true' otherwise.
8-
* Adds attribute 'tabIndex=0' to 'root' slot if 'active' property is true. Sets the attribute to '-1' otherwise.
911
*/
1012
const carouselItemBehavior: Accessibility<CarouselItemProps> = props => ({
1113
attributes: {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { carouselItemBehavior } from '@fluentui/accessibility'
2+
3+
describe('carouselItemBehavior.ts', () => {
4+
test('set tabIndex="0" when carousel has navigation and item is visible ', () => {
5+
const expectedResult = carouselItemBehavior({ navigation: true, active: true })
6+
expect(expectedResult.attributes.root.tabIndex).toEqual(0)
7+
})
8+
9+
test('set tabIndex="-1" when carousel has navigation and item is NOT visible ', () => {
10+
const expectedResult = carouselItemBehavior({ navigation: true, active: false })
11+
expect(expectedResult.attributes.root.tabIndex).toEqual(-1)
12+
})
13+
14+
test('set tabIndex="-1" when carousel has NO navigation and item is visible', () => {
15+
const expectedResult = carouselItemBehavior({ navigation: false, active: true })
16+
expect(expectedResult.attributes.root.tabIndex).toEqual(-1)
17+
})
18+
19+
test('set tabIndex="-1" when carousel has NO navigation and item is NOT visible', () => {
20+
const expectedResult = carouselItemBehavior({ navigation: false, active: false })
21+
expect(expectedResult.attributes.root.tabIndex).toEqual(-1)
22+
})
23+
})

0 commit comments

Comments
 (0)