@orangesk/orange-design-system 2.0.0-beta.19 → 2.0.0-beta.20
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.
- package/README.md +346 -19
- package/build/components/Accordion/style.css +1 -1
- package/build/components/Accordion/style.css.map +1 -1
- package/build/components/Alert/style.css +1 -1
- package/build/components/Alert/style.css.map +1 -1
- package/build/components/AnchorNavigation/style.css +1 -1
- package/build/components/AnchorNavigation/style.css.map +1 -1
- package/build/components/BlockAction/style.css +1 -1
- package/build/components/BlockAction/style.css.map +1 -1
- package/build/components/CarouselPromotions/style.css +1 -1
- package/build/components/CarouselPromotions/style.css.map +1 -1
- package/build/components/FeatureAccordion/style.css +1 -1
- package/build/components/FeatureAccordion/style.css.map +1 -1
- package/build/components/Footer/style.css +1 -1
- package/build/components/Footer/style.css.map +1 -1
- package/build/components/Hero/style.css +1 -1
- package/build/components/Hero/style.css.map +1 -1
- package/build/components/Megamenu/style.css +1 -1
- package/build/components/Megamenu/style.css.map +1 -1
- package/build/components/Modal/style.css +1 -1
- package/build/components/Modal/style.css.map +1 -1
- package/build/components/Progress/style.css +1 -1
- package/build/components/Progress/style.css.map +1 -1
- package/build/components/PromoBanner/style.css +1 -1
- package/build/components/PromoBanner/style.css.map +1 -1
- package/build/components/PromotionCard/style.css +1 -1
- package/build/components/PromotionCard/style.css.map +1 -1
- package/build/components/Tag/style.css +1 -1
- package/build/components/Tag/style.css.map +1 -1
- package/build/components/Tile/style.css +1 -1
- package/build/components/Tile/style.css.map +1 -1
- package/build/components/index.js +1 -1
- package/build/components/index.js.map +1 -1
- package/build/components/tsconfig.tsbuildinfo +1 -1
- package/build/components/types/index.d.ts +5 -40
- package/build/components/types/src/components/Alert/Alert.d.ts +0 -2
- package/build/components/types/src/components/AnchorNavigation/AnchorNavigation.d.ts +1 -2
- package/build/components/types/src/components/BlockAction/BlockAction.d.ts +2 -0
- package/build/components/types/src/components/BlockAction/Context.d.ts +2 -0
- package/build/components/types/src/components/Breadcrumbs/Breadcrumbs.d.ts +0 -2
- package/build/components/types/src/components/Button/Button.d.ts +0 -1
- package/build/components/types/src/components/Card/index.d.ts +1 -0
- package/build/components/types/src/components/Carousel/Carousel.d.ts +0 -2
- package/build/components/types/src/components/CarouselHero/CarouselHero.d.ts +0 -1
- package/build/components/types/src/components/CarouselPromotions/CarouselPromotions.d.ts +0 -1
- package/build/components/types/src/components/Controls/Controls.d.ts +0 -1
- package/build/components/types/src/components/Expander/Expander.d.ts +0 -3
- package/build/components/types/src/components/FeatureAccordion/FeatureAccordion.d.ts +0 -2
- package/build/components/types/src/components/Forms/InputStepper/InputStepper.d.ts +0 -1
- package/build/components/types/src/components/Hero/Hero.d.ts +0 -3
- package/build/components/types/src/components/Icon/iconSearchTags.d.ts +167 -166
- package/build/components/types/src/components/Link/Link.d.ts +0 -2
- package/build/components/types/src/components/Megamenu/static.d.ts +2 -3
- package/build/components/types/src/components/Modal/Modal.d.ts +0 -2
- package/build/components/types/src/components/Pagination/Pagination.d.ts +0 -2
- package/build/components/types/src/components/Pill/Pill.d.ts +0 -1
- package/build/components/types/src/components/Progress/Progress.d.ts +0 -1
- package/build/components/types/src/components/PromoBanner/PromoBanner.d.ts +1 -2
- package/build/components/types/src/components/PromotionCard/PromotionCard.d.ts +2 -2
- package/build/components/types/src/components/Stepbar/Stepbar.d.ts +0 -2
- package/build/components/types/src/components/Table/Table.d.ts +0 -2
- package/build/components/types/src/components/Tabs/Tabs.d.ts +0 -2
- package/build/components/types/src/components/Tooltip/Tooltip.d.ts +0 -1
- package/build/components/types/src/scripts/index.d.ts +2 -3
- package/build/components/types/src/styles/export/color.d.ts +102 -20
- package/build/lib/base.css +1 -1
- package/build/lib/base.css.map +1 -1
- package/build/lib/components.css +1 -1
- package/build/lib/components.css.map +1 -1
- package/build/lib/footer.css +1 -1
- package/build/lib/footer.css.map +1 -1
- package/build/lib/megamenu.css +1 -1
- package/build/lib/megamenu.css.map +1 -1
- package/build/lib/megamenu.js +1 -1
- package/build/lib/megamenu.js.map +1 -1
- package/build/lib/scripts.js +1 -1
- package/build/lib/scripts.js.map +1 -1
- package/build/lib/style.css +1 -1
- package/build/lib/style.css.map +1 -1
- package/build/lib/tsconfig.tsbuildinfo +1 -1
- package/build/lib/utilities.css +1 -1
- package/build/lib/utilities.css.map +1 -1
- package/build/sprite.svg +1 -1
- package/package.json +13 -13
- package/src/assets/icons/quote.svg +4 -0
- package/src/components/Accordion/styles/mixins.scss +2 -0
- package/src/components/Alert/Alert.tsx +0 -6
- package/src/components/Alert/styles/mixins.scss +3 -1
- package/src/components/Alert/tests/Alert.test.js +0 -14
- package/src/components/AnchorNavigation/AnchorNavigation.tsx +1 -10
- package/src/components/AnchorNavigation/tests/AnchorNavigation.conformance.test.js +0 -9
- package/src/components/BlockAction/BlockAction.tsx +10 -3
- package/src/components/BlockAction/Context.tsx +4 -0
- package/src/components/BlockAction/styles/mixins.scss +6 -0
- package/src/components/BlockAction/styles/style.scss +5 -0
- package/src/components/Breadcrumbs/BreadcrumbItem.tsx +16 -7
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +4 -12
- package/src/components/Breadcrumbs/tests/BreadcrumbItem.unit.test.js +14 -8
- package/src/components/Breadcrumbs/tests/Breadcrumbs.integration.test.js +14 -37
- package/src/components/Breadcrumbs/tests/Breadcrumbs.unit.test.js +19 -23
- package/src/components/Button/Button.tsx +0 -4
- package/src/components/Button/tests/Button.test.js +0 -10
- package/src/components/Card/index.ts +1 -0
- package/src/components/Carousel/Carousel.static.ts +5 -0
- package/src/components/Carousel/Carousel.tsx +0 -5
- package/src/components/Carousel/tests/Carousel.unit.test.js +0 -21
- package/src/components/CarouselHero/CarouselHero.tsx +1 -9
- package/src/components/CarouselHero/tests/CarouselHero.conformance.test.js +0 -1
- package/src/components/CarouselHero/tests/CarouselHero.unit.test.js +0 -14
- package/src/components/CarouselPromotions/CarouselPromotions.tsx +1 -6
- package/src/components/CarouselPromotions/styles/mixins.scss +6 -3
- package/src/components/CarouselPromotions/tests/CarouselPromotions.unit.test.js +0 -17
- package/src/components/Controls/Controls.tsx +2 -7
- package/src/components/Controls/tests/Controls.test.js +0 -23
- package/src/components/Expander/Expander.tsx +0 -6
- package/src/components/Expander/tests/Expander.conformance.test.js +8 -12
- package/src/components/Expander/tests/Expander.unit.test.js +37 -47
- package/src/components/FeatureAccordion/FeatureAccordion.tsx +2 -12
- package/src/components/FeatureAccordion/styles/mixins.scss +6 -14
- package/src/components/FeatureAccordion/styles/style.scss +2 -4
- package/src/components/FeatureAccordion/tests/FeatureAccordion.unit.test.js +0 -5
- package/src/components/Footer/styles/mixins.scss +1 -0
- package/src/components/Forms/InputStepper/InputStepper.tsx +0 -4
- package/src/components/Forms/Label/styles/config.scss +3 -0
- package/src/components/Hero/Hero.tsx +2 -16
- package/src/components/Hero/styles/style.scss +0 -14
- package/src/components/Hero/tests/Hero.unit.test.js +109 -119
- package/src/components/Icon/iconSearchTags.ts +167 -166
- package/src/components/Link/Link.tsx +0 -5
- package/src/components/Link/tests/Link.conformance.test.js +1 -7
- package/src/components/Link/tests/Link.unit.test.js +0 -20
- package/src/components/Megamenu/static.ts +5 -2
- package/src/components/Modal/Modal.tsx +0 -5
- package/src/components/Modal/styles/mixins.scss +7 -0
- package/src/components/Modal/styles/style.scss +1 -0
- package/src/components/Modal/tests/Modal.unit.test.js +0 -22
- package/src/components/Pagination/Pagination.tsx +1 -11
- package/src/components/Pill/Pill.tsx +0 -4
- package/src/components/Pill/tests/Pill.conformance.test.js +0 -4
- package/src/components/Pill/tests/Pill.unit.test.js +0 -18
- package/src/components/Progress/Progress.tsx +1 -13
- package/src/components/Progress/styles/mixins.scss +9 -7
- package/src/components/PromoBanner/PromoBanner.tsx +1 -10
- package/src/components/PromoBanner/styles/mixins.scss +0 -3
- package/src/components/PromoBanner/tests/PromoBanner.conformance.test.js +0 -30
- package/src/components/PromoBanner/tests/PromoBanner.unit.test.js +1 -33
- package/src/components/PromotionCard/PromotionCard.tsx +4 -6
- package/src/components/PromotionCard/styles/mixins.scss +1 -0
- package/src/components/PromotionCard/tests/PromotionCard.conformance.test.js +18 -19
- package/src/components/PromotionCard/tests/PromotionCard.unit.test.js +12 -74
- package/src/components/Stepbar/Stepbar.tsx +0 -5
- package/src/components/Table/Table.tsx +0 -5
- package/src/components/Table/tests/Table.unit.test.js +0 -31
- package/src/components/Tabs/Tabs.tsx +0 -5
- package/src/components/Tabs/tests/Tabs.unit.test.js +0 -8
- package/src/components/Tag/styles/config.scss +1 -1
- package/src/components/Tag/styles/style.scss +10 -9
- package/src/components/Tile/styles/mixins.scss +1 -0
- package/src/components/Tooltip/Tooltip.tsx +1 -10
- package/src/components/Tooltip/tests/Tooltip.unit.test.js +0 -29
- package/src/styles/base/globals.scss +9 -0
- package/src/styles/base/styleguide.scss +6 -2
- package/src/styles/export/color.js +102 -20
- package/src/styles/export/color.scss +10 -20
- package/src/styles/typography/config.scss +83 -37
- package/src/styles/typography/mixins.scss +3 -3
- package/src/styles/utilities/text.scss +26 -2
- package/src/components/Pagination/tests/utils.js +0 -12
|
@@ -8,7 +8,6 @@ import { Grid, GridCol } from "../Grid";
|
|
|
8
8
|
import { Image } from "../Image";
|
|
9
9
|
import { Sticker } from "../Sticker";
|
|
10
10
|
|
|
11
|
-
export type HeroBackground = "white" | "black" | "gray";
|
|
12
11
|
export type HeroTextSize = "medium" | "large";
|
|
13
12
|
export type StickerColor = "black" | "orange";
|
|
14
13
|
|
|
@@ -48,8 +47,6 @@ export interface HeroStickerProps {
|
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
export interface HeroProps {
|
|
51
|
-
/** Background spanning whole viewport width */
|
|
52
|
-
colorScheme?: HeroBackground;
|
|
53
50
|
/** Action button props */
|
|
54
51
|
button?: HeroButtonProps;
|
|
55
52
|
/** Main text */
|
|
@@ -80,7 +77,6 @@ const textSizes = {
|
|
|
80
77
|
|
|
81
78
|
export const Hero: React.FC<HeroProps> = ({
|
|
82
79
|
button,
|
|
83
|
-
colorScheme,
|
|
84
80
|
description,
|
|
85
81
|
hasGradientOverlay,
|
|
86
82
|
image,
|
|
@@ -95,11 +91,7 @@ export const Hero: React.FC<HeroProps> = ({
|
|
|
95
91
|
("default" in image && image.default && Object.keys(image).length === 1)
|
|
96
92
|
: false;
|
|
97
93
|
|
|
98
|
-
const className = cx("hero"
|
|
99
|
-
"is-dark": colorScheme === "black",
|
|
100
|
-
"is-light": colorScheme === "white",
|
|
101
|
-
"is-gray": colorScheme === "gray",
|
|
102
|
-
});
|
|
94
|
+
const className = cx("hero");
|
|
103
95
|
return (
|
|
104
96
|
<div className={className}>
|
|
105
97
|
<Container>
|
|
@@ -135,13 +127,7 @@ export const Hero: React.FC<HeroProps> = ({
|
|
|
135
127
|
)}
|
|
136
128
|
</p>
|
|
137
129
|
)}
|
|
138
|
-
{button &&
|
|
139
|
-
<Button
|
|
140
|
-
type="primary"
|
|
141
|
-
colorScheme={colorScheme === "black" ? "light" : "light"}
|
|
142
|
-
{...button}
|
|
143
|
-
/>
|
|
144
|
-
)}
|
|
130
|
+
{button && <Button type="primary" {...button} />}
|
|
145
131
|
</GridCol>
|
|
146
132
|
{sticker && (
|
|
147
133
|
<GridCol
|
|
@@ -5,12 +5,6 @@
|
|
|
5
5
|
@layer components {
|
|
6
6
|
.hero {
|
|
7
7
|
@include mixins.base;
|
|
8
|
-
&.is-gray {
|
|
9
|
-
--color-background-primary: var(--color-surface-subtle);
|
|
10
|
-
.sticker--orange {
|
|
11
|
-
--color-text-default: #ffffff !important;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
8
|
|
|
15
9
|
&__content {
|
|
16
10
|
@include mixins.content;
|
|
@@ -42,14 +36,6 @@
|
|
|
42
36
|
&--gradient {
|
|
43
37
|
@include mixins.gradient-overlay;
|
|
44
38
|
|
|
45
|
-
//stylelint-disable max-nesting-depth
|
|
46
|
-
// @include mixins.gradient-overlay-color();
|
|
47
|
-
.bg-black & {
|
|
48
|
-
// @include mixins.gradient-overlay-color("black");
|
|
49
|
-
}
|
|
50
|
-
.bg-gray & {
|
|
51
|
-
// @include mixins.gradient-overlay-color("gray");
|
|
52
|
-
}
|
|
53
39
|
&-halfwidth {
|
|
54
40
|
@include mixins.gradient-overlay-halfwidth;
|
|
55
41
|
}
|
|
@@ -1,257 +1,247 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { render } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@testing-library/react";
|
|
3
3
|
|
|
4
|
-
import { Hero } from
|
|
4
|
+
import { Hero } from "../";
|
|
5
5
|
|
|
6
6
|
const image = {
|
|
7
|
-
default:
|
|
8
|
-
sm:
|
|
9
|
-
lg:
|
|
10
|
-
xl:
|
|
11
|
-
xxl:
|
|
7
|
+
default: "test-img",
|
|
8
|
+
sm: "test-img-sm",
|
|
9
|
+
lg: "test-img-lg",
|
|
10
|
+
xl: "test-img-xl",
|
|
11
|
+
xxl: "test-img-xxl",
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
// title is required
|
|
15
|
-
describe(
|
|
16
|
-
describe(
|
|
17
|
-
it(
|
|
15
|
+
describe("rendering Hero", () => {
|
|
16
|
+
describe("initial state", () => {
|
|
17
|
+
it("has default class hero", () => {
|
|
18
18
|
const { container } = render(<Hero title="test-title" />);
|
|
19
|
-
expect(container.getElementsByClassName(
|
|
19
|
+
expect(container.getElementsByClassName("hero").length).toBe(1);
|
|
20
20
|
});
|
|
21
|
-
it(
|
|
21
|
+
it("has default class justify-content-space-between", () => {
|
|
22
22
|
const { container } = render(<Hero title="test-title" />);
|
|
23
23
|
expect(
|
|
24
|
-
container.getElementsByClassName(
|
|
24
|
+
container.getElementsByClassName("justify-content-space-between")
|
|
25
|
+
.length,
|
|
25
26
|
).toBe(1);
|
|
26
27
|
});
|
|
27
|
-
it(
|
|
28
|
+
it("has default class hero__content", () => {
|
|
28
29
|
const { container } = render(<Hero title="test-title" />);
|
|
29
|
-
expect(container.getElementsByClassName(
|
|
30
|
+
expect(container.getElementsByClassName("hero__content").length).toBe(1);
|
|
30
31
|
});
|
|
31
|
-
it(
|
|
32
|
+
it("has default class h2", () => {
|
|
32
33
|
const { container } = render(<Hero title="test-title" />);
|
|
33
|
-
expect(container.getElementsByClassName(
|
|
34
|
+
expect(container.getElementsByClassName("h2").length).toBe(1);
|
|
34
35
|
});
|
|
35
36
|
});
|
|
36
37
|
|
|
37
|
-
describe(
|
|
38
|
-
it(
|
|
38
|
+
describe("passed title and description props", () => {
|
|
39
|
+
it("has class hero__description when description is set", () => {
|
|
39
40
|
const { container } = render(
|
|
40
|
-
<Hero description="test-description" title="test-title"
|
|
41
|
+
<Hero description="test-description" title="test-title" />,
|
|
41
42
|
);
|
|
42
|
-
expect(container.getElementsByClassName(
|
|
43
|
-
1
|
|
43
|
+
expect(container.getElementsByClassName("hero__description").length).toBe(
|
|
44
|
+
1,
|
|
44
45
|
);
|
|
45
46
|
});
|
|
46
|
-
it(
|
|
47
|
+
it("has class bold when description is set", () => {
|
|
47
48
|
const { container } = render(
|
|
48
|
-
<Hero description="test-description" title="test-title"
|
|
49
|
+
<Hero description="test-description" title="test-title" />,
|
|
49
50
|
);
|
|
50
|
-
expect(container.getElementsByClassName(
|
|
51
|
+
expect(container.getElementsByClassName("bold").length).toBe(1);
|
|
51
52
|
});
|
|
52
|
-
it(
|
|
53
|
+
it("has class h1 when textSize is set to large", () => {
|
|
53
54
|
const { container } = render(
|
|
54
|
-
<Hero textSize="large" title="test-title"
|
|
55
|
+
<Hero textSize="large" title="test-title" />,
|
|
55
56
|
);
|
|
56
|
-
expect(container.getElementsByClassName(
|
|
57
|
+
expect(container.getElementsByClassName("h1").length).toBe(1);
|
|
57
58
|
});
|
|
58
|
-
it(
|
|
59
|
+
it("has class large bold when description is set and textSize is set to large", () => {
|
|
59
60
|
const { container } = render(
|
|
60
61
|
<Hero
|
|
61
62
|
description="test-description"
|
|
62
63
|
textSize="large"
|
|
63
64
|
title="test-title"
|
|
64
|
-
|
|
65
|
+
/>,
|
|
65
66
|
);
|
|
66
|
-
expect(container.getElementsByClassName(
|
|
67
|
-
expect(container.getElementsByClassName(
|
|
67
|
+
expect(container.getElementsByClassName("large").length).toBe(1);
|
|
68
|
+
expect(container.getElementsByClassName("bold").length).toBe(1);
|
|
68
69
|
});
|
|
69
|
-
it(
|
|
70
|
+
it("renders title", () => {
|
|
70
71
|
const { getByText } = render(<Hero title="test-title" />);
|
|
71
|
-
expect(getByText(
|
|
72
|
+
expect(getByText("test-title")).toBeInTheDocument();
|
|
72
73
|
});
|
|
73
|
-
it(
|
|
74
|
+
it("renders description", () => {
|
|
74
75
|
const { getByText } = render(
|
|
75
|
-
<Hero description="test-description" title="test-title"
|
|
76
|
+
<Hero description="test-description" title="test-title" />,
|
|
76
77
|
);
|
|
77
|
-
expect(getByText(
|
|
78
|
+
expect(getByText("test-description")).toBeInTheDocument();
|
|
78
79
|
});
|
|
79
80
|
});
|
|
80
|
-
describe(
|
|
81
|
-
it(
|
|
81
|
+
describe("passed price prop", () => {
|
|
82
|
+
it("has classes h2 & hero__price when price is set", () => {
|
|
82
83
|
const { container } = render(
|
|
83
|
-
<Hero price="test-price" title="test-title"
|
|
84
|
+
<Hero price="test-price" title="test-title" />,
|
|
84
85
|
);
|
|
85
|
-
expect(container.getElementsByClassName(
|
|
86
|
-
expect(container.getElementsByClassName(
|
|
86
|
+
expect(container.getElementsByClassName("h2").length).toBe(2); // title + price
|
|
87
|
+
expect(container.getElementsByClassName("hero__price").length).toBe(1);
|
|
87
88
|
});
|
|
88
|
-
it(
|
|
89
|
+
it("renders price when price is string", () => {
|
|
89
90
|
const { getByText } = render(
|
|
90
|
-
<Hero price="test-price" title="test-title"
|
|
91
|
+
<Hero price="test-price" title="test-title" />,
|
|
91
92
|
);
|
|
92
|
-
expect(getByText(
|
|
93
|
+
expect(getByText("test-price")).toBeInTheDocument();
|
|
93
94
|
});
|
|
94
|
-
it(
|
|
95
|
+
it("renders price when price is object", () => {
|
|
95
96
|
const { getByText } = render(
|
|
96
97
|
<Hero
|
|
97
98
|
price={{
|
|
98
99
|
amount: 10.99,
|
|
99
|
-
prefix:
|
|
100
|
-
suffix:
|
|
100
|
+
prefix: "test-prefix",
|
|
101
|
+
suffix: "test-suffix",
|
|
101
102
|
}}
|
|
102
103
|
title="test-title"
|
|
103
|
-
|
|
104
|
+
/>,
|
|
104
105
|
);
|
|
105
|
-
expect(getByText(
|
|
106
|
+
expect(getByText("test-prefix10,99 €test-suffix")).toBeInTheDocument();
|
|
106
107
|
});
|
|
107
108
|
});
|
|
108
|
-
describe(
|
|
109
|
-
it(
|
|
109
|
+
describe("passed button prop", () => {
|
|
110
|
+
it("renders button element when button prop is set", () => {
|
|
110
111
|
const { container } = render(
|
|
111
|
-
<Hero button={{ children:
|
|
112
|
+
<Hero button={{ children: "btn-test" }} title="test-title" />,
|
|
112
113
|
);
|
|
113
|
-
expect(container.getElementsByClassName(
|
|
114
|
+
expect(container.getElementsByClassName("btn").length).toBe(1);
|
|
114
115
|
});
|
|
115
116
|
it("button's children are rendered", () => {
|
|
116
117
|
const { getByText } = render(
|
|
117
|
-
<Hero button={{ children:
|
|
118
|
+
<Hero button={{ children: "btn-test" }} title="test-title" />,
|
|
118
119
|
);
|
|
119
|
-
expect(getByText(
|
|
120
|
-
});
|
|
121
|
-
it('button has is-light class when background prop is set to black', () => {
|
|
122
|
-
const { container } = render(
|
|
123
|
-
<Hero
|
|
124
|
-
button={{ children: 'btn-test' }}
|
|
125
|
-
title="test-title"
|
|
126
|
-
colorScheme="black"
|
|
127
|
-
/>
|
|
128
|
-
);
|
|
129
|
-
expect(container.getElementsByClassName('is-light').length).toBe(1);
|
|
120
|
+
expect(getByText("btn-test")).toBeInTheDocument();
|
|
130
121
|
});
|
|
131
122
|
});
|
|
132
|
-
describe(
|
|
133
|
-
it(
|
|
123
|
+
describe("passed sticker prop", () => {
|
|
124
|
+
it("renders sticker element when sticker prop is set", () => {
|
|
134
125
|
const { container } = render(
|
|
135
|
-
<Hero sticker={{ children:
|
|
126
|
+
<Hero sticker={{ children: "sticker-test" }} title="test-title" />,
|
|
136
127
|
);
|
|
137
|
-
expect(container.getElementsByClassName(
|
|
128
|
+
expect(container.getElementsByClassName("sticker").length).toBe(1);
|
|
138
129
|
});
|
|
139
130
|
it("sticker's children are rendered", () => {
|
|
140
131
|
const { getByText } = render(
|
|
141
|
-
<Hero sticker={{ children:
|
|
132
|
+
<Hero sticker={{ children: "sticker-test" }} title="test-title" />,
|
|
142
133
|
);
|
|
143
|
-
expect(getByText(
|
|
134
|
+
expect(getByText("sticker-test")).toBeInTheDocument();
|
|
144
135
|
});
|
|
145
|
-
it(
|
|
136
|
+
it("sticker has class hero__sticker", () => {
|
|
146
137
|
const { container } = render(
|
|
147
|
-
<Hero sticker={{ children:
|
|
138
|
+
<Hero sticker={{ children: "sticker-test" }} title="test-title" />,
|
|
148
139
|
);
|
|
149
|
-
expect(container.getElementsByClassName(
|
|
140
|
+
expect(container.getElementsByClassName("hero__sticker").length).toBe(1);
|
|
150
141
|
});
|
|
151
|
-
it(
|
|
142
|
+
it("sticker has additional class when set in sticker prop", () => {
|
|
152
143
|
const { container } = render(
|
|
153
144
|
<Hero
|
|
154
145
|
sticker={{
|
|
155
|
-
children:
|
|
156
|
-
className:
|
|
146
|
+
children: "sticker-test",
|
|
147
|
+
className: "sticker-test-class",
|
|
157
148
|
}}
|
|
158
149
|
title="test-title"
|
|
159
|
-
|
|
150
|
+
/>,
|
|
160
151
|
);
|
|
161
|
-
expect(container.getElementsByClassName(
|
|
152
|
+
expect(container.getElementsByClassName("hero__sticker").length).toBe(1);
|
|
162
153
|
expect(
|
|
163
|
-
container.getElementsByClassName(
|
|
154
|
+
container.getElementsByClassName("sticker-test-class").length,
|
|
164
155
|
).toBe(1);
|
|
165
156
|
});
|
|
166
|
-
[
|
|
157
|
+
["black", "orange"].map((color) => {
|
|
167
158
|
it(`sticker has sticker--${color} class when sticker.color is set to ${color}`, () => {
|
|
168
159
|
const { container } = render(
|
|
169
160
|
<Hero
|
|
170
|
-
sticker={{ children:
|
|
161
|
+
sticker={{ children: "btn-test", color: color }}
|
|
171
162
|
title="test-title"
|
|
172
|
-
|
|
173
|
-
/>
|
|
163
|
+
/>,
|
|
174
164
|
);
|
|
175
165
|
expect(
|
|
176
|
-
container.getElementsByClassName(`sticker--${color}`).length
|
|
166
|
+
container.getElementsByClassName(`sticker--${color}`).length,
|
|
177
167
|
).toBe(1);
|
|
178
168
|
});
|
|
179
169
|
});
|
|
180
170
|
});
|
|
181
|
-
describe(
|
|
182
|
-
it(
|
|
171
|
+
describe("passed image prop", () => {
|
|
172
|
+
it("renders image element when image prop is set", () => {
|
|
183
173
|
const { container } = render(<Hero image={image} title="test-title" />);
|
|
184
|
-
expect(container.getElementsByClassName(
|
|
174
|
+
expect(container.getElementsByClassName("img").length).toBe(1);
|
|
185
175
|
});
|
|
186
|
-
it(
|
|
176
|
+
it("image has additional class hero__image", () => {
|
|
187
177
|
const { container } = render(<Hero image={image} title="test-title" />);
|
|
188
|
-
expect(container.getElementsByClassName(
|
|
178
|
+
expect(container.getElementsByClassName("hero__image").length).toBe(1);
|
|
189
179
|
});
|
|
190
|
-
it(
|
|
180
|
+
it("image has additional class hero__image--single if single size image is used", () => {
|
|
191
181
|
const { container } = render(
|
|
192
|
-
<Hero image={{ src:
|
|
182
|
+
<Hero image={{ src: "text-img-single" }} title="test-title" />,
|
|
193
183
|
);
|
|
194
184
|
expect(
|
|
195
|
-
container.getElementsByClassName(
|
|
185
|
+
container.getElementsByClassName("hero__image--single").length,
|
|
196
186
|
).toBe(1);
|
|
197
187
|
});
|
|
198
|
-
it(
|
|
188
|
+
it("image has additional class hero__image--fullwidth if prop hasFullwidthImage is passed", () => {
|
|
199
189
|
const { container } = render(
|
|
200
|
-
<Hero image={image} hasFullwidthImage title="test-title"
|
|
190
|
+
<Hero image={image} hasFullwidthImage title="test-title" />,
|
|
201
191
|
);
|
|
202
192
|
expect(
|
|
203
|
-
container.getElementsByClassName(
|
|
193
|
+
container.getElementsByClassName("hero__image--fullwidth").length,
|
|
204
194
|
).toBe(1);
|
|
205
195
|
});
|
|
206
196
|
it("image's attribute src is set to image.default", () => {
|
|
207
197
|
const { container } = render(<Hero image={image} title="test-title" />);
|
|
208
|
-
expect(container.querySelector(
|
|
209
|
-
|
|
198
|
+
expect(container.querySelector("img").getAttribute("src")).toBe(
|
|
199
|
+
"test-img",
|
|
210
200
|
);
|
|
211
201
|
});
|
|
212
202
|
it("image's attribute src is set to image.src if passed as single image", () => {
|
|
213
203
|
const { container } = render(
|
|
214
|
-
<Hero image={{ src:
|
|
204
|
+
<Hero image={{ src: "test-img-single" }} title="test-title" />,
|
|
215
205
|
);
|
|
216
|
-
expect(container.querySelector(
|
|
217
|
-
|
|
206
|
+
expect(container.querySelector("img").getAttribute("src")).toBe(
|
|
207
|
+
"test-img-single",
|
|
218
208
|
);
|
|
219
209
|
});
|
|
220
|
-
[
|
|
210
|
+
["test-img-xxl", "test-img-xl", "test-img-lg", "test-img-sm"].map(
|
|
221
211
|
(size, index) => {
|
|
222
212
|
it(`${
|
|
223
213
|
index + 1
|
|
224
214
|
}. source element has attribute srcSet is set to ${size}`, () => {
|
|
225
215
|
const { container } = render(
|
|
226
|
-
<Hero image={image} title="test-title"
|
|
216
|
+
<Hero image={image} title="test-title" />,
|
|
227
217
|
);
|
|
228
218
|
expect(
|
|
229
|
-
container.querySelectorAll(
|
|
219
|
+
container.querySelectorAll("source")[index].getAttribute("srcSet"),
|
|
230
220
|
).toBe(size);
|
|
231
221
|
});
|
|
232
|
-
}
|
|
222
|
+
},
|
|
233
223
|
);
|
|
234
|
-
it(
|
|
224
|
+
it("image wrapper with class hero__image-wrapper is rendered", () => {
|
|
235
225
|
const { container } = render(<Hero image={image} title="test-title" />);
|
|
236
226
|
expect(
|
|
237
|
-
container.getElementsByClassName(
|
|
227
|
+
container.getElementsByClassName("hero__image-wrapper").length,
|
|
238
228
|
).toBe(1);
|
|
239
229
|
});
|
|
240
|
-
it(
|
|
230
|
+
it("image has additional class hero__image--gradient when prop hasGradientOverlay is passed", () => {
|
|
241
231
|
const { container } = render(
|
|
242
|
-
<Hero hasGradientOverlay image={image} title="test-title"
|
|
232
|
+
<Hero hasGradientOverlay image={image} title="test-title" />,
|
|
243
233
|
);
|
|
244
234
|
expect(
|
|
245
|
-
container.getElementsByClassName(
|
|
235
|
+
container.getElementsByClassName("hero__image--gradient").length,
|
|
246
236
|
).toBe(1);
|
|
247
237
|
});
|
|
248
|
-
it(
|
|
238
|
+
it("image has additional class hero__image--gradient-halfwidth when prop hasGradientOverlay is passed", () => {
|
|
249
239
|
const { container } = render(
|
|
250
|
-
<Hero hasGradientOverlay image={image} title="test-title"
|
|
240
|
+
<Hero hasGradientOverlay image={image} title="test-title" />,
|
|
251
241
|
);
|
|
252
242
|
expect(
|
|
253
|
-
container.getElementsByClassName(
|
|
254
|
-
.length
|
|
243
|
+
container.getElementsByClassName("hero__image--gradient-halfwidth")
|
|
244
|
+
.length,
|
|
255
245
|
).toBe(1);
|
|
256
246
|
});
|
|
257
247
|
it("image doesn't have class hero__image--gradient-halfwidth when prop hasFullwidthImage is also passed", () => {
|
|
@@ -261,11 +251,11 @@ describe('rendering Hero', () => {
|
|
|
261
251
|
hasFullwidthImage
|
|
262
252
|
image={image}
|
|
263
253
|
title="test-title"
|
|
264
|
-
|
|
254
|
+
/>,
|
|
265
255
|
);
|
|
266
256
|
expect(
|
|
267
|
-
container.getElementsByClassName(
|
|
268
|
-
.length
|
|
257
|
+
container.getElementsByClassName("hero__image--gradient-halfwidth")
|
|
258
|
+
.length,
|
|
269
259
|
).toBe(0);
|
|
270
260
|
});
|
|
271
261
|
});
|