@sproutsocial/racine 11.4.1-input-beta.0 → 11.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,113 +0,0 @@
1
- import React from "react";
2
- import { fireEvent, render } from "../utils/react-testing-library";
3
- import "jest-styled-components";
4
- import Button from "./";
5
-
6
- describe("Racine Button", () => {
7
- it("should render in default style", () => {
8
- const { container } = render(<Button>Button</Button>);
9
- expect(container).toMatchSnapshot();
10
- });
11
- it("should render in primary style", () => {
12
- const { container } = render(<Button appearance="primary">Button</Button>);
13
- expect(container).toMatchSnapshot();
14
- });
15
- it("should render in secondary style", () => {
16
- const { container } = render(
17
- <Button appearance="secondary">Button</Button>
18
- );
19
- expect(container).toMatchSnapshot();
20
- });
21
-
22
- it("should render in pill style", () => {
23
- const { container } = render(<Button shape="pill">Button</Button>);
24
- expect(container).toMatchSnapshot();
25
- });
26
-
27
- it("should render in an anchor tag with external target", () => {
28
- const { container } = render(
29
- <Button href="http://sproutsocial.style" external>
30
- Button
31
- </Button>
32
- );
33
- expect(container).toMatchSnapshot();
34
- });
35
-
36
- it("should render in large size", () => {
37
- const { container } = render(
38
- <Button appearance="secondary" size="large">
39
- Button
40
- </Button>
41
- );
42
- expect(container).toMatchSnapshot();
43
- });
44
-
45
- it("should render in active state", () => {
46
- const { container } = render(
47
- <Button appearance="secondary" active>
48
- Button
49
- </Button>
50
- );
51
- expect(container).toMatchSnapshot();
52
- });
53
-
54
- it("setting external to prop true should add target blank attribute to anchor", () => {
55
- const { getByText } = render(
56
- <Button href="http://sproutsocial.com" external>
57
- Link
58
- </Button>
59
- );
60
- expect(getByText("Link").target).toEqual("_blank");
61
- });
62
-
63
- it("setting external to prop true should add rel='noopener noreferrer' attribute", () => {
64
- const { getByText } = render(
65
- <Button href="http://sproutsocial.com" external>
66
- Link
67
- </Button>
68
- );
69
- expect(getByText("Link").rel).toEqual("noopener noreferrer");
70
- });
71
-
72
- it("setting a URL renders component as an Anchor", () => {
73
- const { getByText } = render(
74
- <Button href="http://sproutsocial.com">Am I an anchor?</Button>
75
- );
76
- // expect(wrapper.find("a").length).toEqual(1);
77
- expect(getByText("Am I an anchor?").tagName).toEqual("A");
78
- });
79
-
80
- it("should only submit a form when given type=submit", () => {
81
- const onSubmit = jest.fn();
82
- const { queryByText } = render(
83
- <form onSubmit={onSubmit}>
84
- <Button>Not Submit</Button>
85
- <Button type="submit">Submit</Button>
86
- </form>
87
- );
88
- fireEvent.click(queryByText("Not Submit"));
89
- expect(onSubmit).not.toHaveBeenCalled();
90
- fireEvent.click(queryByText("Submit"));
91
- expect(onSubmit).toHaveBeenCalled();
92
- });
93
-
94
- it("Has type attribute as button by default", () => {
95
- const { getByText } = render(<Button>My Button</Button>);
96
- expect(getByText("My Button").type).toEqual("button");
97
- });
98
-
99
- it("Does not have type attribute when given href attribute", () => {
100
- const { getByText } = render(<Button href="google.com">My Button</Button>);
101
- expect(getByText("My Button").type).toBeFalsy();
102
- expect(getByText("My Button").type).not.toEqual("button");
103
- });
104
-
105
- it("Had overriden type attribute", () => {
106
- const { getByText } = render(
107
- <Button href="google.com" type="button">
108
- My Button
109
- </Button>
110
- );
111
- expect(getByText("My Button").type).toEqual("button");
112
- });
113
- });