Source code
Revision control
Copy as Markdown
Other Tools
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
"use strict";
const { mount } = require("enzyme");
const {
createFactory,
} = require("resource://devtools/client/shared/vendor/react.js");
const Provider = createFactory(
require("resource://devtools/client/shared/vendor/react-redux.js").Provider
);
const {
setupStore,
const BadgeClass = require("resource://devtools/client/accessibility/components/Badge.js");
const Badge = createFactory(BadgeClass);
describe("Badge component:", () => {
const label = "Contrast";
const tooltip = "Does not meet WCAG standards for accessible text.";
const props = { label, tooltip };
it("basic render", () => {
const store = setupStore();
const wrapper = mount(Provider({ store }, Badge(props)));
expect(wrapper.html()).toMatchSnapshot();
const badge = wrapper.find(BadgeClass);
expect(badge.children().length).toBe(1);
expect(
badge.find(`span[aria-label="${label}"][title="${tooltip}"]`)
).toHaveLength(1);
const badgeText = badge.childAt(0);
expect(badgeText.hasClass("audit-badge")).toBe(true);
expect(badgeText.hasClass("badge")).toBe(true);
expect(badgeText.text()).toBe(label);
});
});