text-label-check.test.js (1644B)
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 { mount } = require("enzyme"); 8 const { 9 createFactory, 10 } = require("resource://devtools/client/shared/vendor/react.mjs"); 11 const TextLabelCheckClass = require("resource://devtools/client/accessibility/components/TextLabelCheck.js"); 12 const TextLabelCheck = createFactory(TextLabelCheckClass); 13 14 const FluentReact = require("resource://devtools/client/shared/vendor/fluent-react.js"); 15 const LocalizationProvider = createFactory(FluentReact.LocalizationProvider); 16 17 const { 18 testCustomCheck, 19 } = require("resource://devtools/client/accessibility/test/node/helpers.js"); 20 21 const { 22 accessibility: { 23 AUDIT_TYPE: { TEXT_LABEL }, 24 ISSUE_TYPE: { 25 [TEXT_LABEL]: { 26 AREA_NO_NAME_FROM_ALT, 27 DIALOG_NO_NAME, 28 FORM_NO_VISIBLE_NAME, 29 }, 30 }, 31 SCORES: { BEST_PRACTICES, FAIL, WARNING }, 32 }, 33 } = require("resource://devtools/shared/constants.js"); 34 35 describe("TextLabelCheck component:", () => { 36 const testProps = [ 37 { issue: AREA_NO_NAME_FROM_ALT, score: FAIL }, 38 { issue: FORM_NO_VISIBLE_NAME, score: WARNING }, 39 { issue: DIALOG_NO_NAME, score: BEST_PRACTICES }, 40 ]; 41 42 for (const props of testProps) { 43 it(`${props.score} render`, () => { 44 const wrapper = mount( 45 LocalizationProvider({ bundles: [] }, TextLabelCheck(props)) 46 ); 47 48 const textLabelCheck = wrapper.find(TextLabelCheckClass); 49 testCustomCheck(textLabelCheck, props); 50 }); 51 } 52 });