/** * Prepare the store for use in testing.
*/ function setupStore({ preloadedState } = {}) { const store = createStore(combineReducers(reducers), preloadedState); return store;
}
/** * Build a mock accessible object. * @param {Object} form * Data similar to what accessible actor passes to accessible front.
*/ function mockAccessible(form) { return {
on: jest.fn(),
off: jest.fn(),
isDestroyed: () => !form?.actorID,
audit: jest.fn().mockReturnValue(Promise.resolve()),
...form,
};
}
/** * * @param {DOMNode} * DOMNode that corresponds to a menu item in a menu list * @param {Object} * Expected properties: * - role: optional ARIA role for the menu item * - checked: optional checked state for the menu item * - disabled: optional disabled state for the menu item * - label: optional text label for the menu item
*/ function checkMenuItem(menuItem, expected) {
expect(menuItem.tagName).toBe("BUTTON"); if (expected.role) {
expect(menuItem.getAttribute("role")).toBe(expected.role);
} elseif (typeof expected.checked !== "undefined") {
expect(menuItem.getAttribute("role")).toBe("menuitemcheckbox");
} else {
expect(menuItem.getAttribute("role")).toBe("menuitem");
}
if (typeof expected.checked !== "undefined") {
expect(menuItem.hasAttribute("aria-checked")).toBe(expected.checked);
}
if (expected.checked) {
expect(menuItem.getAttribute("aria-checked")).toBe("true");
}
if (expected.disabled) {
expect(menuItem.hasAttribute("disabled")).toBe(true);
}
if (expected.label) {
expect(menuItem.textContent).toBe(expected.label);
}
}
/** * * @param {ReactWrapper} * React wrapper for the top level check component. * @param {Object} * Expected audit properties: * - score: audit score * - issue: audit issue type
*/ function testCustomCheck(wrapper, props) {
expect(wrapper.html()).toMatchSnapshot();
expect(wrapper.children().length).toBe(1); const check = wrapper.childAt(0);
expect(wrapper.find(CheckClass)).toStrictEqual(check);
testCheck(check, props);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.