tor-browser

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

check.test.js (1556B)


      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 "use strict";
      5 
      6 const { mount } = require("enzyme");
      7 
      8 const {
      9  createFactory,
     10 } = require("resource://devtools/client/shared/vendor/react.mjs");
     11 const CheckClass = require("resource://devtools/client/accessibility/components/Check.js");
     12 const Check = createFactory(CheckClass);
     13 
     14 const FluentReact = require("resource://devtools/client/shared/vendor/fluent-react.js");
     15 const LocalizationProvider = createFactory(FluentReact.LocalizationProvider);
     16 
     17 const {
     18  accessibility: {
     19    AUDIT_TYPE: { TEXT_LABEL },
     20    ISSUE_TYPE: {
     21      [TEXT_LABEL]: { AREA_NO_NAME_FROM_ALT },
     22    },
     23    SCORES: { FAIL },
     24  },
     25 } = require("resource://devtools/shared/constants.js");
     26 
     27 const {
     28  testCheck,
     29 } = require("resource://devtools/client/accessibility/test/node/helpers.js");
     30 
     31 describe("Check component:", () => {
     32  const props = {
     33    id: "accessibility-text-label-header",
     34    issue: AREA_NO_NAME_FROM_ALT,
     35    score: FAIL,
     36    getAnnotation: jest.fn(),
     37  };
     38 
     39  it("basic render", () => {
     40    const wrapper = mount(LocalizationProvider({ bundles: [] }, Check(props)));
     41    expect(wrapper.html()).toMatchSnapshot();
     42 
     43    testCheck(wrapper.childAt(0), {
     44      issue: AREA_NO_NAME_FROM_ALT,
     45      score: FAIL,
     46    });
     47    expect(props.getAnnotation.mock.calls.length).toBe(1);
     48    expect(props.getAnnotation.mock.calls[0]).toEqual([AREA_NO_NAME_FROM_ALT]);
     49  });
     50 });