tor-browser

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

HelpText.test.jsx (1429B)


      1 import { HelpText } from "content-src/components/HelpText";
      2 import { Localized } from "content-src/components/MSLocalized";
      3 import React from "react";
      4 import { shallow } from "enzyme";
      5 
      6 describe("<HelpText>", () => {
      7  it("should render text inside Localized", () => {
      8    const shallowWrapper = shallow(<HelpText text="test" />);
      9 
     10    assert.equal(shallowWrapper.find(Localized).props().text, "test");
     11  });
     12  it("should render the img if there is an img and a string_id", () => {
     13    const shallowWrapper = shallow(
     14      <HelpText
     15        text={{ string_id: "test_id" }}
     16        hasImg={{
     17          src: "chrome://activity-stream/content/data/content/assets/cfr_fb_container.png",
     18        }}
     19      />
     20    );
     21    assert.ok(
     22      shallowWrapper
     23        .find(Localized)
     24        .findWhere(n => n.text.string_id === "test_id")
     25    );
     26    assert.lengthOf(shallowWrapper.find("p.helptext"), 1);
     27    assert.lengthOf(shallowWrapper.find("img[data-l10n-name='help-img']"), 1);
     28  });
     29  it("should render the img if there is an img and plain text", () => {
     30    const shallowWrapper = shallow(
     31      <HelpText
     32        text={"Sample help text"}
     33        hasImg={{
     34          src: "chrome://activity-stream/content/data/content/assets/cfr_fb_container.png",
     35        }}
     36      />
     37    );
     38    assert.equal(shallowWrapper.find("p.helptext").text(), "Sample help text");
     39    assert.lengthOf(shallowWrapper.find("img.helptext-img"), 1);
     40  });
     41 });