Sha256: f33a4ab3b31b346dd43b56efe56e2294b220fe1176279a932bb0f9bbeaf8af22

Contents?: true

Size: 1.47 KB

Versions: 482

Compression:

Stored size: 1.47 KB

Contents

import React from 'react'
import { render, screen, cleanup } from "../utilities/test-utils";

import { Hashtag } from "playbook-ui";


const testId = "primary-test"
const text="Open in a new window"
const type="project"
const url="https://google.com"
const typeMap = {
  home: 'H#',
  project: 'P#',
  appointment: 'A#',
  default: '#',
}

function HashtagTest(props) {
    return (
        <Hashtag
            data={{ testid: testId }}
            text={text}
            type={type}
            url={url}
            {...props}
        />
    );
  }

  test("renders the component", () => {
    render(<HashtagTest/>);
    const kit = screen.getByTestId("primary-test");
    expect(kit).toBeInTheDocument();
    expect(kit).toHaveClass("pb_hashtag_kit");

    cleanup()
  });

  test("should pass in url property and allow links to open in a new window", () => {
    const { container } = render(<HashtagTest newWindow />);
    expect(container.getElementsByClassName("pb_hashtag_kit")[0].firstChild).toHaveAttribute("href", url);
    expect(container.getElementsByClassName("pb_hashtag_kit")[0].firstChild).toHaveAttribute("target", "_blank");

    cleanup()
  });

  test("renders the badge kit with appropriate text", () => {
    const { container } = render(<HashtagTest />);
    expect(container.getElementsByClassName("pb_badge_kit_primary")[0]).toBeInTheDocument;
    expect(container.getElementsByClassName("pb_badge_kit_primary")[0]).toHaveTextContent(typeMap[type] + text);

    cleanup()
  });

Version data entries

482 entries across 482 versions & 1 rubygems

Version Path
playbook_ui-14.11.1.pre.alpha.PLAY17445539 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR798datepickerturbo5537 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.11.1.pre.alpha.pbntr703collapsiblerowsrails5536 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.11.1.pre.alpha.PLAY1751pbcontenttagpt25529 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR7495495 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.12.0.pre.rc.11 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.12.0.pre.rc.10 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.12.0.pre.rc.9 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.12.0.pre.rc.8 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.12.0.pre.rc.7 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5437 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR719listdraggablesimple5432 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR768stickyrightcolumn5431 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.12.0.pre.rc.6 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5415 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5413 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.12.0.pre.rc.5 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5409 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5400 app/pb_kits/playbook/pb_hashtag/hashtag.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5392 app/pb_kits/playbook/pb_hashtag/hashtag.test.js