keyboard-check.test.js (1518B)
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 KeyboardCheckClass = require("resource://devtools/client/accessibility/components/KeyboardCheck.js"); 12 const KeyboardCheck = createFactory(KeyboardCheckClass); 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: { KEYBOARD }, 24 ISSUE_TYPE: { 25 [KEYBOARD]: { INTERACTIVE_NO_ACTION, FOCUSABLE_NO_SEMANTICS }, 26 }, 27 SCORES: { FAIL, WARNING }, 28 }, 29 } = require("resource://devtools/shared/constants.js"); 30 31 describe("KeyboardCheck component:", () => { 32 const testProps = [ 33 { score: FAIL, issue: INTERACTIVE_NO_ACTION }, 34 { score: WARNING, issue: FOCUSABLE_NO_SEMANTICS }, 35 ]; 36 37 for (const props of testProps) { 38 it(`${props.score} render`, () => { 39 const wrapper = mount( 40 LocalizationProvider({ bundles: [] }, KeyboardCheck(props)) 41 ); 42 43 const keyboardCheck = wrapper.find(KeyboardCheckClass); 44 testCustomCheck(keyboardCheck, props); 45 }); 46 } 47 });