GithubHelp home page GithubHelp logo

royalicing / auditioner Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 628 KB

Does your component have enough to get the role? Accessibility-first testing.

License: MIT License

Makefile 0.26% TypeScript 96.88% JavaScript 2.86%
accessibility-testing accessibility components react aria web vue

auditioner's Introduction

auditioner

๐ŸŽฌ

Test that your components can play the accessibility roles we need.


Roles

  • button
  • link
  • checkbox
  • radiogroup / radio
  • tab
  • menu
  • summary

Tabs

Examples

import { screenTest, Tab } from 'auditioner';

describe('your tabs component', () => {
  beforeEach(() => render(<Tabs />));

  it('renders 3 tabs', () => {
    expect(screenTest(Tab.all)).toHaveLength(3);
  });

  it('has first tab', () => {
    expect(screenTest(Tab('First'))).toBeVisible();
  });

  it('selects first tab', () => {
    expect(screenTest(Tab('First').selected)).toBeVisible();
  });

  it('renders first tabpanel', () => {
    expect(screenTest(Tab.panel())).toHaveTextContent('First panel');
  });

  it('labels first tabpanel', () => {
    expect(screenTest(Tab.panel('First'))).toHaveTextContent('First panel');
  });

  it('renders tablist', () => {
    expect(screenTest(Tab.list())).toBeVisible();
  });

  describe('when clicking on second tab', () => {
    beforeEach(() => {
      user.click(screenTest(Tab('Second')));
    });

    it('selects second tab', () => {
      expect(screenTest(Tab('Second').selected)).toBeVisible();
    });

    it('renders second tabpanel', () => {
      expect(screenTest(Tab.panel())).toHaveTextContent('Second panel');
    });
  });
});

Menus

Examples

import { Button, Menu, screenTest } from 'auditioner';
import user from '@testing-library/user-event';

describe('your menu component', () => {
  beforeEach(() => {
    render(<YourMenu />);
  });

  describe('when action menu is clicked', () => {
    beforeEach(() => user.click(screenTest(Button('Actions'))));

    it('opens menu', () => {
      expect(screenTest(Menu('Actions'))).toBeVisible();
    });

    it('has Cut item', () => {
      expect(screenTest(Menu.item('Cut'))).toBeVisible();
    });

    it('renders 3 menu items: Cut, Copy, Paste', () => {
      const [first, second, third] = screenTest(Menu.item().all);
      expect(first).toHaveAccessibleName('Cut');
      expect(second).toHaveAccessibleName('Copy');
      expect(third).toHaveAccessibleName('Paste');
    });

    describe('when clicking on Cut item', () => {
      beforeEach(() => {
        user.click(screenTest(Menu.item('Cut')));
      });

      it('calls select with cut', () => {
        expect(dispatch).toHaveBeenCalledWith({ type: 'select', id: 'cut' });
      });
    });
  });
});

Checkboxes

Examples

import { Checkbox, screenTest } from 'auditioner';

describe('your form component', () => {
  beforeEach(() => {
    render(<YourForm />);
  });

  it('has First checkbox', () => {
    expect(screenTest(Checkbox('First'))).toBeVisible();
  });

  it('has 3 checkboxes', () => {
    expect(screenTest(Checkbox.all)).toHaveLength(3);
  });
});

Scene

(COMING SOON?)

import { scene } from 'auditioner';

expect(
  screenTest(
    scene(
      form('Sign up', [
        textbox('Email address'),
        textbox('Password'),
        button('Sign up'),
      ])
    )
  )
).toBe(true);

auditioner's People

Contributors

royalicing avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

auditioner's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.