Accessibility is only about adding alternative text to images
Accessibility is only about following the WCAG
Accessibility can be achieved by only adding ARIA attributes
https://www.w3.org/TR/wai-aria-1.1/
The first rule of ARIA is don’t use it
Accessibility can only be tested by disabled people
import React from 'react'
import { render, fireEvent } from '@testing-library/react'
import Dropdown from '../dropdown'
describe(`Dropdown`, () => {
it(`renders a focusable button that activates the dropdown`, () => {
const activatorText = `Fruits`
const items = [{
text: 'Apple',
url: '#'
}, {
text: 'Grapes',
url: '#'
}]
const dropdown = render(<Dropdown activatorText={activatorText} items={items} />)
const activator = dropdown.getByTestId('dropdown-activator')
activator.focus()
expect(activator).toHaveFocus()
fireEvent.click(activator)
const dropdownList = dropdown.getByTestId('dropdown-itemList')
const firstAnchor = dropdownList.querySelector('a')
expect(firstAnchor).toHaveFocus()
})
})
// Menu links //Button
// Example //<button className="moveToPreviousLink"/>
// <ul data-id="url-navigations">
// -- <li>
// <a href="/conf">Conference</a>
// </li>
// -- City guide
// -- Concerts
// -- History
// </ul>
describe ('A11y test', () => {
it('should focus skip button then return to the previous page by click', () => {
cy.visit('https://my-page-path')
cy.get('[data-id="url-navigations"]').click();
cy.focused.should('have.class', 'moveToPreviousLink')
})
})
Accessibility is optional
croftyland