tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

keyboard-badge.test.js (2001B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 const { shallow, mount } = require("enzyme");
      8 
      9 const {
     10  createFactory,
     11 } = require("resource://devtools/client/shared/vendor/react.mjs");
     12 
     13 const Provider = createFactory(
     14  require("resource://devtools/client/shared/vendor/react-redux.js").Provider
     15 );
     16 const {
     17  setupStore,
     18 } = require("resource://devtools/client/accessibility/test/node/helpers.js");
     19 
     20 const Badge = require("resource://devtools/client/accessibility/components/Badge.js");
     21 const KeyboardBadgeClass = require("resource://devtools/client/accessibility/components/KeyboardBadge.js");
     22 const KeyboardBadge = createFactory(KeyboardBadgeClass);
     23 const {
     24  accessibility: { SCORES },
     25 } = require("resource://devtools/shared/constants.js");
     26 
     27 function testBadge(wrapper) {
     28  expect(wrapper.html()).toMatchSnapshot();
     29  expect(wrapper.children().length).toBe(1);
     30  const keyboardBadge = wrapper.find(KeyboardBadgeClass);
     31  const badge = keyboardBadge.childAt(0);
     32  expect(badge.type()).toBe(Badge);
     33  expect(badge.props()).toMatchObject({
     34    label: "keyboard",
     35    tooltip: "Does not meet WCAG standards for keyboard accessibility.",
     36  });
     37 }
     38 
     39 describe("KeyboardBadge component:", () => {
     40  const store = setupStore();
     41 
     42  it("error render", () => {
     43    const wrapper = shallow(KeyboardBadge({ error: true }));
     44    expect(wrapper.html()).toMatchSnapshot();
     45    expect(wrapper.isEmptyRender()).toBe(true);
     46  });
     47 
     48  it("fail render", () => {
     49    const wrapper = mount(
     50      Provider(
     51        { store },
     52        KeyboardBadge({
     53          score: SCORES.FAIL,
     54        })
     55      )
     56    );
     57 
     58    testBadge(wrapper);
     59  });
     60 
     61  it("warning render", () => {
     62    const wrapper = mount(
     63      Provider(
     64        { store },
     65        KeyboardBadge({
     66          score: SCORES.WARNING,
     67        })
     68      )
     69    );
     70 
     71    testBadge(wrapper);
     72  });
     73 });