@patternfly/react-core 4.258.4 → 4.258.6

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/esm/components/Button/__mocks__/Button.d.ts +8 -0
  3. package/dist/esm/components/Button/__mocks__/Button.d.ts.map +1 -0
  4. package/dist/esm/components/Button/__mocks__/Button.js +14 -0
  5. package/dist/esm/components/Button/__mocks__/Button.js.map +1 -0
  6. package/dist/esm/components/Button/__mocks__/index.d.ts +2 -0
  7. package/dist/esm/components/Button/__mocks__/index.d.ts.map +1 -0
  8. package/dist/esm/components/Button/__mocks__/index.js +2 -0
  9. package/dist/esm/components/Button/__mocks__/index.js.map +1 -0
  10. package/dist/js/components/Button/__mocks__/Button.d.ts +8 -0
  11. package/dist/js/components/Button/__mocks__/Button.d.ts.map +1 -0
  12. package/dist/js/components/Button/__mocks__/Button.js +18 -0
  13. package/dist/js/components/Button/__mocks__/Button.js.map +1 -0
  14. package/dist/js/components/Button/__mocks__/index.d.ts +2 -0
  15. package/dist/js/components/Button/__mocks__/index.d.ts.map +1 -0
  16. package/dist/js/components/Button/__mocks__/index.js +5 -0
  17. package/dist/js/components/Button/__mocks__/index.js.map +1 -0
  18. package/dist/umd/react-core.min.css +64 -64
  19. package/package.json +2 -2
  20. package/src/components/Alert/__tests__/AlertActionCloseButton.test.tsx +10 -21
  21. package/src/components/Alert/__tests__/AlertActionLink.test.tsx +1 -10
  22. package/src/components/Alert/__tests__/AlertToggleExpandButton.test.tsx +1 -12
  23. package/src/components/Alert/__tests__/__snapshots__/AlertActionCloseButton.test.tsx.snap +9 -0
  24. package/src/components/Alert/__tests__/__snapshots__/AlertActionLink.test.tsx.snap +11 -0
  25. package/src/components/Alert/__tests__/__snapshots__/AlertToggleExpandButton.test.tsx.snap +9 -0
  26. package/src/components/BackToTop/__tests__/BackToTop.test.tsx +3 -12
  27. package/src/components/BackToTop/__tests__/__snapshots__/BackToTop.test.tsx.snap +10 -2
  28. package/src/components/Backdrop/__tests__/Backdrop.test.tsx +36 -2
  29. package/src/components/Backdrop/__tests__/__snapshots__/Backdrop.test.tsx.snap +1 -1
  30. package/src/components/Button/__mocks__/Button.tsx +17 -0
  31. package/src/components/Button/__mocks__/index.ts +1 -0
  32. package/src/components/Label/examples/LabelCompact.tsx +2 -2
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.258.6](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-core@4.258.5...@patternfly/react-core@4.258.6) (2022-11-04)
7
+
8
+ **Note:** Version bump only for package @patternfly/react-core
9
+
10
+
11
+
12
+
13
+
14
+ ## 4.258.5 (2022-11-04)
15
+
16
+ **Note:** Version bump only for package @patternfly/react-core
17
+
18
+
19
+
20
+
21
+
6
22
  ## 4.258.4 (2022-11-01)
7
23
 
8
24
  **Note:** Version bump only for package @patternfly/react-core
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { ButtonProps } from '../';
3
+ export declare const Button: ({ children, variant, isInline, onClick, iconPosition, icon, ...props }: ButtonProps) => JSX.Element;
4
+ export declare const ButtonVariant: {
5
+ plain: string;
6
+ link: string;
7
+ };
8
+ //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/__mocks__/Button.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAElC,eAAO,MAAM,MAAM,2EAA4E,WAAW,gBAWzG,CAAC;AAEF,eAAO,MAAM,aAAa;;;CAAmC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { __rest } from "tslib";
2
+ import React from 'react';
3
+ export const Button = (_a) => {
4
+ var { children, variant, isInline, onClick, iconPosition, icon } = _a, props = __rest(_a, ["children", "variant", "isInline", "onClick", "iconPosition", "icon"]);
5
+ return (React.createElement(React.Fragment, null,
6
+ React.createElement("button", Object.assign({ onClick: onClick }, props), children),
7
+ React.createElement("p", null, `variant: ${variant}`),
8
+ React.createElement("p", { id: "labelling-id" }, "Test label"),
9
+ React.createElement("p", null, `isInline: ${isInline}`),
10
+ React.createElement("p", null, `iconPosition: ${iconPosition}`),
11
+ React.createElement("div", { "data-testid": "icon" }, icon)));
12
+ };
13
+ export const ButtonVariant = { plain: 'plain', link: 'link' };
14
+ //# sourceMappingURL=Button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../../src/components/Button/__mocks__/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EAAmF,EAAE,EAAE;QAAvF,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,OAAyB,EAApB,KAAK,cAApE,sEAAsE,CAAF;IAAoB,OAAA,CAC7G;QACE,8CAAQ,OAAO,EAAE,OAAO,IAAM,KAAK,GAChC,QAAQ,CACF;QACT,+BAAI,YAAY,OAAO,EAAE,CAAK;QAC9B,2BAAG,EAAE,EAAC,cAAc,iBAAe;QACnC,+BAAI,aAAa,QAAQ,EAAE,CAAK;QAChC,+BAAI,iBAAiB,YAAY,EAAE,CAAK;QACxC,4CAAiB,MAAM,IAAE,IAAI,CAAO,CACnC,CACJ,CAAA;CAAA,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './Button';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/__mocks__/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './Button';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/Button/__mocks__/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { ButtonProps } from '../';
3
+ export declare const Button: ({ children, variant, isInline, onClick, iconPosition, icon, ...props }: ButtonProps) => JSX.Element;
4
+ export declare const ButtonVariant: {
5
+ plain: string;
6
+ link: string;
7
+ };
8
+ //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/__mocks__/Button.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAElC,eAAO,MAAM,MAAM,2EAA4E,WAAW,gBAWzG,CAAC;AAEF,eAAO,MAAM,aAAa;;;CAAmC,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ButtonVariant = exports.Button = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const Button = (_a) => {
7
+ var { children, variant, isInline, onClick, iconPosition, icon } = _a, props = tslib_1.__rest(_a, ["children", "variant", "isInline", "onClick", "iconPosition", "icon"]);
8
+ return (react_1.default.createElement(react_1.default.Fragment, null,
9
+ react_1.default.createElement("button", Object.assign({ onClick: onClick }, props), children),
10
+ react_1.default.createElement("p", null, `variant: ${variant}`),
11
+ react_1.default.createElement("p", { id: "labelling-id" }, "Test label"),
12
+ react_1.default.createElement("p", null, `isInline: ${isInline}`),
13
+ react_1.default.createElement("p", null, `iconPosition: ${iconPosition}`),
14
+ react_1.default.createElement("div", { "data-testid": "icon" }, icon)));
15
+ };
16
+ exports.Button = Button;
17
+ exports.ButtonVariant = { plain: 'plain', link: 'link' };
18
+ //# sourceMappingURL=Button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../../src/components/Button/__mocks__/Button.tsx"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAGnB,MAAM,MAAM,GAAG,CAAC,EAAmF,EAAE,EAAE;QAAvF,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,OAAyB,EAApB,KAAK,sBAApE,sEAAsE,CAAF;IAAoB,OAAA,CAC7G;QACE,wDAAQ,OAAO,EAAE,OAAO,IAAM,KAAK,GAChC,QAAQ,CACF;QACT,yCAAI,YAAY,OAAO,EAAE,CAAK;QAC9B,qCAAG,EAAE,EAAC,cAAc,iBAAe;QACnC,yCAAI,aAAa,QAAQ,EAAE,CAAK;QAChC,yCAAI,iBAAiB,YAAY,EAAE,CAAK;QACxC,sDAAiB,MAAM,IAAE,IAAI,CAAO,CACnC,CACJ,CAAA;CAAA,CAAC;AAXW,QAAA,MAAM,UAWjB;AAEW,QAAA,aAAa,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './Button';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/__mocks__/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./Button"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/Button/__mocks__/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB"}
@@ -1862,6 +1862,70 @@ textarea.pf-c-form-control {
1862
1862
  color: var(--pf-global--palette--black-900);
1863
1863
  }
1864
1864
 
1865
+ .pf-c-brand {
1866
+ --pf-c-brand--Width: auto;
1867
+ --pf-c-brand--Height: auto;
1868
+ width: var(--pf-c-brand--Width--base);
1869
+ height: var(--pf-c-brand--Height--base);
1870
+ --pf-c-brand--Width--base: var(--pf-c-brand--Width);
1871
+ --pf-c-brand--Height--base: var(--pf-c-brand--Height);
1872
+ }
1873
+
1874
+ @media (min-width: 576px) {
1875
+ .pf-c-brand {
1876
+ --pf-c-brand--Width--base: var(--pf-c-brand--Width-on-sm, var(--pf-c-brand--Width));
1877
+ }
1878
+ }
1879
+ @media (min-width: 768px) {
1880
+ .pf-c-brand {
1881
+ --pf-c-brand--Width--base: var(--pf-c-brand--Width-on-md, var(--pf-c-brand--Width-on-sm, var(--pf-c-brand--Width)));
1882
+ }
1883
+ }
1884
+ @media (min-width: 992px) {
1885
+ .pf-c-brand {
1886
+ --pf-c-brand--Width--base: var(--pf-c-brand--Width-on-lg, var(--pf-c-brand--Width-on-md, var(--pf-c-brand--Width-on-sm, var(--pf-c-brand--Width))));
1887
+ }
1888
+ }
1889
+ @media (min-width: 1200px) {
1890
+ .pf-c-brand {
1891
+ --pf-c-brand--Width--base: var(--pf-c-brand--Width-on-xl, var(--pf-c-brand--Width-on-lg, var(--pf-c-brand--Width-on-md, var(--pf-c-brand--Width-on-sm, var(--pf-c-brand--Width)))));
1892
+ }
1893
+ }
1894
+ @media (min-width: 1450px) {
1895
+ .pf-c-brand {
1896
+ --pf-c-brand--Width--base: var(--pf-c-brand--Width-on-2xl, var(--pf-c-brand--Width-on-xl, var(--pf-c-brand--Width-on-lg, var(--pf-c-brand--Width-on-md, var(--pf-c-brand--Width-on-sm, var(--pf-c-brand--Width))))));
1897
+ }
1898
+ }
1899
+ @media (min-width: 576px) {
1900
+ .pf-c-brand {
1901
+ --pf-c-brand--Height--base: var(--pf-c-brand--Height-on-sm, var(--pf-c-brand--Height));
1902
+ }
1903
+ }
1904
+ @media (min-width: 768px) {
1905
+ .pf-c-brand {
1906
+ --pf-c-brand--Height--base: var(--pf-c-brand--Height-on-md, var(--pf-c-brand--Height-on-sm, var(--pf-c-brand--Height)));
1907
+ }
1908
+ }
1909
+ @media (min-width: 992px) {
1910
+ .pf-c-brand {
1911
+ --pf-c-brand--Height--base: var(--pf-c-brand--Height-on-lg, var(--pf-c-brand--Height-on-md, var(--pf-c-brand--Height-on-sm, var(--pf-c-brand--Height))));
1912
+ }
1913
+ }
1914
+ @media (min-width: 1200px) {
1915
+ .pf-c-brand {
1916
+ --pf-c-brand--Height--base: var(--pf-c-brand--Height-on-xl, var(--pf-c-brand--Height-on-lg, var(--pf-c-brand--Height-on-md, var(--pf-c-brand--Height-on-sm, var(--pf-c-brand--Height)))));
1917
+ }
1918
+ }
1919
+ @media (min-width: 1450px) {
1920
+ .pf-c-brand {
1921
+ --pf-c-brand--Height--base: var(--pf-c-brand--Height-on-2xl, var(--pf-c-brand--Height-on-xl, var(--pf-c-brand--Height-on-lg, var(--pf-c-brand--Height-on-md, var(--pf-c-brand--Height-on-sm, var(--pf-c-brand--Height))))));
1922
+ }
1923
+ }
1924
+ .pf-c-brand.pf-m-picture {
1925
+ display: inline-flex;
1926
+ max-width: 100%;
1927
+ }
1928
+
1865
1929
  .pf-c-breadcrumb {
1866
1930
  --pf-c-breadcrumb__item--FontSize: var(--pf-global--FontSize--sm);
1867
1931
  --pf-c-breadcrumb__item--LineHeight: var(--pf-global--LineHeight--sm);
@@ -1969,70 +2033,6 @@ button.pf-c-breadcrumb__link {
1969
2033
  --pf-c-breadcrumb__item-divider--Color: var(--pf-global--BorderColor--100);
1970
2034
  }
1971
2035
 
1972
- .pf-c-brand {
1973
- --pf-c-brand--Width: auto;
1974
- --pf-c-brand--Height: auto;
1975
- width: var(--pf-c-brand--Width--base);
1976
- height: var(--pf-c-brand--Height--base);
1977
- --pf-c-brand--Width--base: var(--pf-c-brand--Width);
1978
- --pf-c-brand--Height--base: var(--pf-c-brand--Height);
1979
- }
1980
-
1981
- @media (min-width: 576px) {
1982
- .pf-c-brand {
1983
- --pf-c-brand--Width--base: var(--pf-c-brand--Width-on-sm, var(--pf-c-brand--Width));
1984
- }
1985
- }
1986
- @media (min-width: 768px) {
1987
- .pf-c-brand {
1988
- --pf-c-brand--Width--base: var(--pf-c-brand--Width-on-md, var(--pf-c-brand--Width-on-sm, var(--pf-c-brand--Width)));
1989
- }
1990
- }
1991
- @media (min-width: 992px) {
1992
- .pf-c-brand {
1993
- --pf-c-brand--Width--base: var(--pf-c-brand--Width-on-lg, var(--pf-c-brand--Width-on-md, var(--pf-c-brand--Width-on-sm, var(--pf-c-brand--Width))));
1994
- }
1995
- }
1996
- @media (min-width: 1200px) {
1997
- .pf-c-brand {
1998
- --pf-c-brand--Width--base: var(--pf-c-brand--Width-on-xl, var(--pf-c-brand--Width-on-lg, var(--pf-c-brand--Width-on-md, var(--pf-c-brand--Width-on-sm, var(--pf-c-brand--Width)))));
1999
- }
2000
- }
2001
- @media (min-width: 1450px) {
2002
- .pf-c-brand {
2003
- --pf-c-brand--Width--base: var(--pf-c-brand--Width-on-2xl, var(--pf-c-brand--Width-on-xl, var(--pf-c-brand--Width-on-lg, var(--pf-c-brand--Width-on-md, var(--pf-c-brand--Width-on-sm, var(--pf-c-brand--Width))))));
2004
- }
2005
- }
2006
- @media (min-width: 576px) {
2007
- .pf-c-brand {
2008
- --pf-c-brand--Height--base: var(--pf-c-brand--Height-on-sm, var(--pf-c-brand--Height));
2009
- }
2010
- }
2011
- @media (min-width: 768px) {
2012
- .pf-c-brand {
2013
- --pf-c-brand--Height--base: var(--pf-c-brand--Height-on-md, var(--pf-c-brand--Height-on-sm, var(--pf-c-brand--Height)));
2014
- }
2015
- }
2016
- @media (min-width: 992px) {
2017
- .pf-c-brand {
2018
- --pf-c-brand--Height--base: var(--pf-c-brand--Height-on-lg, var(--pf-c-brand--Height-on-md, var(--pf-c-brand--Height-on-sm, var(--pf-c-brand--Height))));
2019
- }
2020
- }
2021
- @media (min-width: 1200px) {
2022
- .pf-c-brand {
2023
- --pf-c-brand--Height--base: var(--pf-c-brand--Height-on-xl, var(--pf-c-brand--Height-on-lg, var(--pf-c-brand--Height-on-md, var(--pf-c-brand--Height-on-sm, var(--pf-c-brand--Height)))));
2024
- }
2025
- }
2026
- @media (min-width: 1450px) {
2027
- .pf-c-brand {
2028
- --pf-c-brand--Height--base: var(--pf-c-brand--Height-on-2xl, var(--pf-c-brand--Height-on-xl, var(--pf-c-brand--Height-on-lg, var(--pf-c-brand--Height-on-md, var(--pf-c-brand--Height-on-sm, var(--pf-c-brand--Height))))));
2029
- }
2030
- }
2031
- .pf-c-brand.pf-m-picture {
2032
- display: inline-flex;
2033
- max-width: 100%;
2034
- }
2035
-
2036
2036
  .pf-c-button {
2037
2037
  --pf-c-button--PaddingTop: var(--pf-global--spacer--form-element);
2038
2038
  --pf-c-button--PaddingRight: var(--pf-global--spacer--md);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.258.4",
3
+ "version": "4.258.6",
4
4
  "description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -70,5 +70,5 @@
70
70
  "react": "^16.8 || ^17 || ^18",
71
71
  "react-dom": "^16.8 || ^17 || ^18"
72
72
  },
73
- "gitHead": "1fa474ac5bfe3fdcd5a1b5c48b0c9d4ca809b79a"
73
+ "gitHead": "418db80c9d90e4a39bac9b24c7869a9ab7d985f5"
74
74
  }
@@ -5,18 +5,7 @@ import userEvent from '@testing-library/user-event';
5
5
  import { AlertActionCloseButton } from '../AlertActionCloseButton';
6
6
  import { AlertContext } from '../AlertContext';
7
7
 
8
- jest.mock('../../Button', () => ({
9
- Button: ({ children, variant, isInline, onClick, ...props }) => (
10
- <>
11
- <button onClick={onClick} {...props}>
12
- {children}
13
- </button>
14
- <p>{`variant: ${variant}`}</p>
15
- <p id="labelling-id">Test label</p>
16
- </>
17
- ),
18
- ButtonVariant: { plain: 'plain' }
19
- }));
8
+ jest.mock('../../Button');
20
9
 
21
10
  test('Renders without children', () => {
22
11
  render(
@@ -98,7 +87,7 @@ test('Renders with an aria label composed with the title and variantLabel provid
98
87
  test('Renders with an aria label composed with the title provided via a context and variantLabel provided via prop', () => {
99
88
  render(
100
89
  <AlertContext.Provider value={{ title: 'title', variantLabel: 'variantLabel' }}>
101
- <AlertActionCloseButton variantLabel='variant label prop'/>
90
+ <AlertActionCloseButton variantLabel="variant label prop" />
102
91
  </AlertContext.Provider>
103
92
  );
104
93
 
@@ -106,14 +95,14 @@ test('Renders with an aria label composed with the title provided via a context
106
95
  });
107
96
 
108
97
  test('Renders with the aria label provided via prop when one is provided', () => {
109
- render(
110
- <AlertContext.Provider value={{ title: 'title', variantLabel: 'variantLabel' }}>
111
- <AlertActionCloseButton aria-label='Aria label prop'/>
112
- </AlertContext.Provider>
113
- );
114
-
115
- expect(screen.getByRole('button')).toHaveAccessibleName('Aria label prop');
116
- });
98
+ render(
99
+ <AlertContext.Provider value={{ title: 'title', variantLabel: 'variantLabel' }}>
100
+ <AlertActionCloseButton aria-label="Aria label prop" />
101
+ </AlertContext.Provider>
102
+ );
103
+
104
+ expect(screen.getByRole('button')).toHaveAccessibleName('Aria label prop');
105
+ });
117
106
 
118
107
  test('Matches the snapshot', () => {
119
108
  const { asFragment } = render(
@@ -2,16 +2,7 @@ import React from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
3
  import { AlertActionLink } from '../AlertActionLink';
4
4
 
5
- jest.mock('../../Button', () => ({
6
- Button: ({ children, variant, isInline, ...props }) => (
7
- <>
8
- <button {...props}>{children}</button>
9
- <p>{`variant: ${variant}`}</p>
10
- <p>{`isInline: ${isInline}`}</p>
11
- </>
12
- ),
13
- ButtonVariant: { link: 'link' }
14
- }));
5
+ jest.mock('../../Button');
15
6
 
16
7
  test('Renders without children', () => {
17
8
  render(
@@ -5,18 +5,7 @@ import userEvent from '@testing-library/user-event';
5
5
  import { AlertToggleExpandButton } from '../AlertToggleExpandButton';
6
6
  import { AlertContext } from '../AlertContext';
7
7
 
8
- jest.mock('../../Button', () => ({
9
- Button: ({ children, variant, isInline, onClick, ...props }) => (
10
- <>
11
- <button onClick={onClick} {...props}>
12
- {children}
13
- </button>
14
- <p>{`variant: ${variant}`}</p>
15
- <p id="labelling-id">Test label</p>
16
- </>
17
- ),
18
- ButtonVariant: { plain: 'plain' }
19
- }));
8
+ jest.mock('../../Button');
20
9
 
21
10
  jest.mock('@patternfly/react-icons/dist/esm/icons/angle-right-icon', () => () => 'Icon mock');
22
11
 
@@ -27,5 +27,14 @@ exports[`Matches the snapshot 1`] = `
27
27
  >
28
28
  Test label
29
29
  </p>
30
+ <p>
31
+ isInline: undefined
32
+ </p>
33
+ <p>
34
+ iconPosition: undefined
35
+ </p>
36
+ <div
37
+ data-testid="icon"
38
+ />
30
39
  </DocumentFragment>
31
40
  `;
@@ -10,8 +10,19 @@ exports[`Matches the snapshot 1`] = `
10
10
  <p>
11
11
  variant: link
12
12
  </p>
13
+ <p
14
+ id="labelling-id"
15
+ >
16
+ Test label
17
+ </p>
13
18
  <p>
14
19
  isInline: true
15
20
  </p>
21
+ <p>
22
+ iconPosition: undefined
23
+ </p>
24
+ <div
25
+ data-testid="icon"
26
+ />
16
27
  </DocumentFragment>
17
28
  `;
@@ -20,5 +20,14 @@ exports[`Matches snapshot 1`] = `
20
20
  >
21
21
  Test label
22
22
  </p>
23
+ <p>
24
+ isInline: undefined
25
+ </p>
26
+ <p>
27
+ iconPosition: undefined
28
+ </p>
29
+ <div
30
+ data-testid="icon"
31
+ />
23
32
  </DocumentFragment>
24
33
  `;
@@ -3,16 +3,7 @@ import { fireEvent, render, screen } from '@testing-library/react';
3
3
  import { BackToTop } from '../BackToTop';
4
4
  import userEvent from '@testing-library/user-event';
5
5
 
6
- jest.mock('../../Button', () => ({
7
- Button: ({ variant, iconPosition, children, icon }) => (
8
- <>
9
- <button>{children}</button>
10
- <p>{variant}</p>
11
- <p>{iconPosition}</p>
12
- <div data-testid="icon">{icon}</div>
13
- </>
14
- )
15
- }));
6
+ jest.mock('../../Button');
16
7
 
17
8
  test('Renders BackToTop', () => {
18
9
  render(
@@ -138,13 +129,13 @@ test('Passes correct text content to button child component', () => {
138
129
  test('Passes correct variant to button child component', () => {
139
130
  render(<BackToTop title="Back to the future" />);
140
131
 
141
- expect(screen.getByText('primary')).toBeVisible();
132
+ expect(screen.getByText('variant: primary')).toBeVisible();
142
133
  });
143
134
 
144
135
  test('Passes correct iconPosition to button child component', () => {
145
136
  render(<BackToTop />);
146
137
 
147
- expect(screen.getByText('right')).toBeVisible();
138
+ expect(screen.getByText('iconPosition: right')).toBeVisible();
148
139
  });
149
140
 
150
141
  test('Passes correct icon to button child component', () => {
@@ -9,10 +9,18 @@ exports[`Matches the snapshot 1`] = `
9
9
  Back to top
10
10
  </button>
11
11
  <p>
12
- primary
12
+ variant: primary
13
+ </p>
14
+ <p
15
+ id="labelling-id"
16
+ >
17
+ Test label
18
+ </p>
19
+ <p>
20
+ isInline: undefined
13
21
  </p>
14
22
  <p>
15
- right
23
+ iconPosition: right
16
24
  </p>
17
25
  <div
18
26
  data-testid="icon"
@@ -1,8 +1,42 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react';
2
+ import { render, screen } from '@testing-library/react';
3
3
  import { Backdrop } from '../Backdrop';
4
4
 
5
- test('Backdrop Test', () => {
5
+ test('Renders without children', () => {
6
+ render(
7
+ <div data-testid="backdrop">
8
+ <Backdrop />
9
+ </div>
10
+ );
11
+ expect(screen.getByTestId('backdrop').firstChild).toBeVisible();
12
+ });
13
+
14
+ test('Renders children', () => {
15
+ render(<Backdrop>Test</Backdrop>);
16
+ expect(screen.getByText('Test')).toBeVisible();
17
+ });
18
+
19
+ test('Renders with the pf-c-backdrop', () => {
20
+ render(<Backdrop>Test</Backdrop>);
21
+ expect(screen.getByText('Test')).toHaveClass('pf-c-backdrop');
22
+ });
23
+
24
+ test('Renders with only the class pf-c-backdrop by default', () => {
25
+ render(<Backdrop>Test</Backdrop>);
26
+ expect(screen.getByText('Test')).toHaveClass('pf-c-backdrop', { exact: true });
27
+ });
28
+
29
+ test('Renders with custom class name when className prop is passed', () => {
30
+ render(<Backdrop className="test-class">Test</Backdrop>);
31
+ expect(screen.getByText('Test')).toHaveClass('test-class');
32
+ });
33
+
34
+ test('Renders with the inherited element props spread to the component', () => {
35
+ render(<Backdrop aria-label="this is a simple backdrop">Test</Backdrop>);
36
+ expect(screen.getByText('Test')).toHaveAccessibleName('this is a simple backdrop');
37
+ });
38
+
39
+ test('Matches the snapshot', () => {
6
40
  const { asFragment } = render(<Backdrop>Backdrop</Backdrop>);
7
41
  expect(asFragment()).toMatchSnapshot();
8
42
  });
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Backdrop Test 1`] = `
3
+ exports[`Matches the snapshot 1`] = `
4
4
  <DocumentFragment>
5
5
  <div
6
6
  class="pf-c-backdrop"
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { ButtonProps } from '../';
3
+
4
+ export const Button = ({ children, variant, isInline, onClick, iconPosition, icon, ...props }: ButtonProps) => (
5
+ <>
6
+ <button onClick={onClick} {...props}>
7
+ {children}
8
+ </button>
9
+ <p>{`variant: ${variant}`}</p>
10
+ <p id="labelling-id">Test label</p>
11
+ <p>{`isInline: ${isInline}`}</p>
12
+ <p>{`iconPosition: ${iconPosition}`}</p>
13
+ <div data-testid="icon">{icon}</div>
14
+ </>
15
+ );
16
+
17
+ export const ButtonVariant = { plain: 'plain', link: 'link' };
@@ -0,0 +1 @@
1
+ export * from './Button';
@@ -14,10 +14,10 @@ export const LabelCompact: React.FunctionComponent = () => (
14
14
  <Label isCompact icon={<InfoCircleIcon />} onClose={() => Function.prototype}>
15
15
  Compact icon removable
16
16
  </Label>{' '}
17
- <Label isCompact href="#outline">
17
+ <Label isCompact href="#compact">
18
18
  Compact link
19
19
  </Label>{' '}
20
- <Label isCompact href="#outline" onClose={() => Function.prototype}>
20
+ <Label isCompact href="#compact" onClose={() => Function.prototype}>
21
21
  Compact link removable
22
22
  </Label>
23
23
  <Label isCompact icon={<InfoCircleIcon />} onClose={() => Function.prototype} isTruncated>