tor-browser

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

components_application_panel-Manifest.test.js (2478B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Import libs
      7 const { shallow } = require("enzyme");
      8 const { createFactory } = require("react");
      9 
     10 const Manifest = createFactory(
     11  require("resource://devtools/client/application/src/components/manifest/Manifest.js")
     12 );
     13 
     14 const {
     15  MANIFEST_COLOR_MEMBERS,
     16  MANIFEST_ICON_MEMBERS,
     17  MANIFEST_STRING_MEMBERS,
     18  MANIFEST_UNKNOWN_TYPE_MEMBERS,
     19  MANIFEST_URL_MEMBERS,
     20  MANIFEST_NO_ISSUES,
     21  MANIFEST_WITH_ISSUES,
     22 } = require("resource://devtools/client/application/test/node/fixtures/data/constants.js");
     23 
     24 /*
     25 * Test for Manifest component
     26 */
     27 
     28 describe("Manifest", () => {
     29  it("renders the expected snapshot for a manifest with string members", () => {
     30    const wrapper = shallow(Manifest(MANIFEST_STRING_MEMBERS));
     31    expect(wrapper).toMatchSnapshot();
     32  });
     33 
     34  it("renders the expected snapshot for a manifest with color members", () => {
     35    const wrapper = shallow(Manifest(MANIFEST_COLOR_MEMBERS));
     36    expect(wrapper).toMatchSnapshot();
     37  });
     38 
     39  it("renders the expected snapshot for a manifest with unknown types", () => {
     40    const wrapper = shallow(Manifest(MANIFEST_UNKNOWN_TYPE_MEMBERS));
     41    expect(wrapper).toMatchSnapshot();
     42  });
     43 
     44  it("renders the expected snapshot for a manifest with icon members", () => {
     45    const wrapper = shallow(Manifest(MANIFEST_ICON_MEMBERS));
     46    expect(wrapper).toMatchSnapshot();
     47  });
     48 
     49  it("renders the expected snapshot for a manifest with url members", () => {
     50    const wrapper = shallow(Manifest(MANIFEST_URL_MEMBERS));
     51    expect(wrapper).toMatchSnapshot();
     52  });
     53 
     54  it("does render the issues section when the manifest is not valid", () => {
     55    const wrapper = shallow(Manifest(MANIFEST_WITH_ISSUES));
     56    expect(wrapper).toMatchSnapshot();
     57 
     58    const sections = wrapper.find("ManifestSection");
     59    expect(sections).toHaveLength(4);
     60    expect(sections.get(0).props.title).toBe("manifest-item-warnings");
     61    expect(sections.find("ManifestIssueList")).toHaveLength(1);
     62  });
     63 
     64  it("does not render the issues section when the manifest is valid", () => {
     65    const wrapper = shallow(Manifest(MANIFEST_NO_ISSUES));
     66    expect(wrapper).toMatchSnapshot();
     67 
     68    const sections = wrapper.find("ManifestSection");
     69    expect(sections).toHaveLength(3);
     70    expect(sections.get(0).props.title).not.toBe("manifest-item-warnings");
     71    expect(sections.find("ManifestIssueList")).toHaveLength(0);
     72  });
     73 });