FollowSectionButtonHighlight.test.jsx (1497B)
1 import { FollowSectionButtonHighlight } from "content-src/components/DiscoveryStreamComponents/FeatureHighlight/FollowSectionButtonHighlight"; 2 import { mount } from "enzyme"; 3 import React from "react"; 4 5 describe("Discovery Stream <FollowSectionButtonHighlight>", () => { 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 <FollowSectionButtonHighlight 22 arrowPosition="arrow-inline-start" 23 dispatch={dispatch} 24 feature="FEATURE_FOLLOW_SECTION_BUTTON" 25 handleBlock={handleBlock} 26 handleDismiss={handleDismiss} 27 isIntersecting={false} 28 messageData={messageData} 29 position="inset-inline-end" 30 verticalPosition="inset-block-center" 31 /> 32 ); 33 }); 34 35 afterEach(() => { 36 sandbox.restore(); 37 }); 38 39 it("should render highlight container", () => { 40 assert.ok(wrapper.exists()); 41 assert.ok(wrapper.find(".follow-section-button-highlight").exists()); 42 }); 43 44 it("should dispatch dismiss event and call handleDismiss and handleBlock", () => { 45 const dismissCallback = wrapper 46 .find("FeatureHighlight") 47 .prop("dismissCallback"); 48 49 dismissCallback(); 50 51 assert(handleDismiss.calledOnce); 52 assert(handleBlock.calledOnce); 53 }); 54 });