tor-browser

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

MSLocalized.test.jsx (1425B)


      1 import { Localized } from "content-src/components/MSLocalized";
      2 import React from "react";
      3 import { shallow } from "enzyme";
      4 
      5 describe("<MSLocalized>", () => {
      6  it("should render span with no children", () => {
      7    const shallowWrapper = shallow(<Localized text="test" />);
      8 
      9    assert.ok(shallowWrapper.find("span").exists());
     10    assert.equal(shallowWrapper.text(), "test");
     11  });
     12  it("should render span when using string_id with no children", () => {
     13    const shallowWrapper = shallow(
     14      <Localized text={{ string_id: "test_id" }} />
     15    );
     16 
     17    assert.ok(shallowWrapper.find("span[data-l10n-id='test_id']").exists());
     18  });
     19  it("should render text inside child", () => {
     20    const shallowWrapper = shallow(
     21      <Localized text="test">
     22        <div />
     23      </Localized>
     24    );
     25 
     26    assert.ok(shallowWrapper.find("div").text(), "test");
     27  });
     28  it("should use l10n id on child", () => {
     29    const shallowWrapper = shallow(
     30      <Localized text={{ string_id: "test_id" }}>
     31        <div />
     32      </Localized>
     33    );
     34 
     35    assert.ok(shallowWrapper.find("div[data-l10n-id='test_id']").exists());
     36  });
     37  it("should keep original children", () => {
     38    const shallowWrapper = shallow(
     39      <Localized text={{ string_id: "test_id" }}>
     40        <h1>
     41          <span data-l10n-name="test" />
     42        </h1>
     43      </Localized>
     44    );
     45 
     46    assert.ok(shallowWrapper.find("span[data-l10n-name='test']").exists());
     47  });
     48 });