tor-browser

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

OnboardingVideoTest.test.jsx (1195B)


      1 import React from "react";
      2 import { mount } from "enzyme";
      3 import { OnboardingVideo } from "content-src/components/OnboardingVideo";
      4 
      5 describe("OnboardingVideo component", () => {
      6  let sandbox;
      7 
      8  beforeEach(async () => {
      9    sandbox = sinon.createSandbox();
     10  });
     11 
     12  afterEach(() => {
     13    sandbox.restore();
     14  });
     15 
     16  const SCREEN_PROPS = {
     17    content: {
     18      title: "Test title",
     19      video_container: {
     20        video_url: "test url",
     21      },
     22    },
     23  };
     24 
     25  it("should handle video_start action when video is played", () => {
     26    const handleAction = sandbox.stub();
     27    const wrapper = mount(
     28      <OnboardingVideo handleAction={handleAction} {...SCREEN_PROPS} />
     29    );
     30    wrapper.find("video").simulate("play");
     31    assert.calledWith(handleAction, {
     32      currentTarget: { value: "video_start" },
     33    });
     34  });
     35  it("should handle video_end action when video has completed playing", () => {
     36    const handleAction = sandbox.stub();
     37    const wrapper = mount(
     38      <OnboardingVideo handleAction={handleAction} {...SCREEN_PROPS} />
     39    );
     40    wrapper.find("video").simulate("ended");
     41    assert.calledWith(handleAction, {
     42      currentTarget: { value: "video_end" },
     43    });
     44  });
     45 });