tor-browser

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

HeroImage.test.jsx (1130B)


      1 import React from "react";
      2 import { shallow } from "enzyme";
      3 import { HeroImage } from "content-src/components/HeroImage";
      4 
      5 describe("HeroImage component", () => {
      6  const imageUrl = "https://example.com";
      7  const imageHeight = "100px";
      8  const imageAlt = "Alt text";
      9 
     10  let wrapper;
     11  beforeEach(() => {
     12    wrapper = shallow(
     13      <HeroImage url={imageUrl} alt={imageAlt} height={imageHeight} />
     14    );
     15  });
     16 
     17  it("should render HeroImage component", () => {
     18    assert.ok(wrapper.exists());
     19  });
     20 
     21  it("should render an image element with src prop", () => {
     22    let imgEl = wrapper.find("img");
     23    assert.strictEqual(imgEl.prop("src"), imageUrl);
     24  });
     25 
     26  it("should render image element with alt text prop", () => {
     27    let imgEl = wrapper.find("img");
     28    assert.equal(imgEl.prop("alt"), imageAlt);
     29  });
     30 
     31  it("should render an image with a set height prop", () => {
     32    let imgEl = wrapper.find("img");
     33    assert.propertyVal(imgEl.prop("style"), "height", imageHeight);
     34  });
     35 
     36  it("should not render HeroImage component", () => {
     37    wrapper.setProps({ url: null });
     38    assert.ok(wrapper.isEmptyRender());
     39  });
     40 });