ShortcutFeatureHighlight.test.jsx (1371B)
1 import React from "react"; 2 import { mount } from "enzyme"; 3 import { ShortcutFeatureHighlight } from "content-src/components/DiscoveryStreamComponents/FeatureHighlight/ShortcutFeatureHighlight"; 4 5 describe("Discovery Stream <ShortcutFeatureHighlight>", () => { 6 let wrapper; 7 let sandbox; 8 let dispatch; 9 let handleDismiss; 10 let handleBlock; 11 let messageData; 12 13 beforeEach(() => { 14 sandbox = sinon.createSandbox(); 15 dispatch = sandbox.stub(); 16 handleDismiss = sandbox.stub(); 17 handleBlock = sandbox.stub(); 18 messageData = sandbox.stub(); 19 20 wrapper = mount( 21 <ShortcutFeatureHighlight 22 dispatch={dispatch} 23 feature="FEATURE_SHORTCUT_HIGHLIGHT" 24 handleBlock={handleBlock} 25 handleDismiss={handleDismiss} 26 messageData={messageData} 27 position="inset-block-end inset-inline-start" 28 /> 29 ); 30 }); 31 32 afterEach(() => { 33 sandbox.restore(); 34 }); 35 36 it("should render highlight container", () => { 37 assert.ok(wrapper.exists()); 38 assert.ok(wrapper.find(".shortcut-feature-highlight").exists()); 39 }); 40 41 it("should dispatch dismiss event and call handleDismiss and handleBlock", () => { 42 const dismissCallback = wrapper 43 .find("FeatureHighlight") 44 .prop("dismissCallback"); 45 46 dismissCallback(); 47 48 assert(handleDismiss.calledOnce); 49 assert(handleBlock.calledOnce); 50 }); 51 });