tor-browser

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

components_application_panel-SidebarItem.test.js (2145B)


      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 {
     11  setupStore,
     12 } = require("resource://devtools/client/application/test/node/helpers.js");
     13 
     14 const {
     15  PAGE_TYPES,
     16 } = require("resource://devtools/client/application/src/constants.js");
     17 
     18 const SidebarItem = createFactory(
     19  require("resource://devtools/client/application/src/components/routing/SidebarItem.js")
     20 );
     21 
     22 /**
     23 * Test for SidebarItem.js component
     24 */
     25 
     26 describe("SidebarItem", () => {
     27  function buildStoreWithSelectedPage(selectedPage) {
     28    return setupStore({
     29      ui: {
     30        selectedPage,
     31      },
     32    });
     33  }
     34 
     35  it("renders the expected snapshot when the manifest page is selected", () => {
     36    const store = buildStoreWithSelectedPage(PAGE_TYPES.MANIFEST);
     37    const wrapper = shallow(
     38      SidebarItem({
     39        store,
     40        page: "manifest",
     41        isSelected: true,
     42      })
     43    ).dive();
     44    expect(wrapper).toMatchSnapshot();
     45  });
     46 
     47  it("renders the expected snapshot when the service-workers page is selected", () => {
     48    const store = buildStoreWithSelectedPage(PAGE_TYPES.SERVICE_WORKERS);
     49    const wrapper = shallow(
     50      SidebarItem({
     51        store,
     52        isSelected: true,
     53        page: "service-workers",
     54      })
     55    ).dive();
     56    expect(wrapper).toMatchSnapshot();
     57  });
     58 
     59  it("renders the expected snapshot when the manifest page is not selected", () => {
     60    const store = buildStoreWithSelectedPage(PAGE_TYPES.MANIFEST);
     61    const wrapper = shallow(
     62      SidebarItem({
     63        store,
     64        isSelected: false,
     65        page: "manifest",
     66      })
     67    ).dive();
     68    expect(wrapper).toMatchSnapshot();
     69  });
     70 
     71  it("renders the expected snapshot when the service-workers page is not selected", () => {
     72    const store = buildStoreWithSelectedPage(PAGE_TYPES.SERVICE_WORKERS);
     73    const wrapper = shallow(
     74      SidebarItem({
     75        store,
     76        isSelected: false,
     77        page: "service-workers",
     78      })
     79    ).dive();
     80    expect(wrapper).toMatchSnapshot();
     81  });
     82 });