components_application_panel-Sidebar.test.js (1479B)
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 Sidebar = createFactory( 19 require("resource://devtools/client/application/src/components/routing/Sidebar.js") 20 ); 21 22 /** 23 * Test for Sidebar.js component 24 */ 25 26 describe("Sidebar", () => { 27 function buildStoreWithSelectedPage(selectedPage) { 28 return setupStore({ 29 ui: { 30 selectedPage, 31 }, 32 }); 33 } 34 it("renders the expected snapshot when the manifest page is selected", () => { 35 const store = buildStoreWithSelectedPage(PAGE_TYPES.MANIFEST); 36 const wrapper = shallow(Sidebar({ store })).dive(); 37 expect(wrapper).toMatchSnapshot(); 38 }); 39 40 it("renders the expected snapshot when the service workers page is selected", () => { 41 const store = buildStoreWithSelectedPage(PAGE_TYPES.SERVICE_WORKERS); 42 const wrapper = shallow(Sidebar({ store })).dive(); 43 expect(wrapper).toMatchSnapshot(); 44 }); 45 46 it("renders the expected snapshot when no page is selected", () => { 47 const store = buildStoreWithSelectedPage(); 48 const wrapper = shallow(Sidebar({ store })).dive(); 49 expect(wrapper).toMatchSnapshot(); 50 }); 51 });