@bytebrand/fe-ui-core 4.2.46 → 4.2.48

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.
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import Badge from '../../../source/components/_common/Badge/Badge';
4
+
5
+ describe('Badge', () => {
6
+ const textToRender = 'Test Text';
7
+
8
+ it('renders without crashing and shows the correct text', () => {
9
+ const type = 'green';
10
+ const { getByText } = render(<Badge type={type}>{textToRender}</Badge>);
11
+ const renderedText = getByText(textToRender);
12
+
13
+ expect(renderedText).toBeInTheDocument();
14
+ });
15
+ });
package/jest.config.js ADDED
@@ -0,0 +1,42 @@
1
+ module.exports = {
2
+ testEnvironment: 'jest-environment-jsdom-sixteen',
3
+ testEnvironmentOptions: {
4
+ userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36',
5
+ },
6
+ roots: [
7
+ "<rootDir>"
8
+ ],
9
+ transform: {
10
+ "^.+\.(ts|tsx)?$": "ts-jest",
11
+ ".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub",
12
+ "^.+\\.svg$": "jest-svg-transformer"
13
+ },
14
+ transformIgnorePatterns: [
15
+ "node_modules/(?!@ngrx|(?!deck.gl)|ng-dynamic)",
16
+ "/node_modules\/(.*)",
17
+ "^.+\\.mock$"
18
+ ],
19
+ testMatch: [ "**/__tests__/**/*.ts?(x)", "**/?(*.)+(spec|test).ts?(x)" ],
20
+ testPathIgnorePatterns: [
21
+ "/node_modules/",
22
+ "/media/",
23
+ "/public/"
24
+ ],
25
+ moduleNameMapper: {
26
+ "^.+.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub",
27
+ "^.+\\.svg$": "jest-svg-transformer",
28
+ "\\.(css|less|scss|sss|styl)$": "<rootDir>/node_modules/jest-css-modules",
29
+ 'react-dom/client': 'react-dom'
30
+ },
31
+ moduleFileExtensions: [
32
+ "js",
33
+ "jsx",
34
+ "ts",
35
+ "tsx",
36
+ "json",
37
+ "node"
38
+ ],
39
+ "coverageDirectory": "__tests__/__snapshots__",
40
+
41
+ "setupFilesAfterEnv": ["<rootDir>/setupTests.js"],
42
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core",
3
- "version": "4.2.46",
3
+ "version": "4.2.48",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -10,9 +10,9 @@
10
10
  "@babel/plugin-proposal-decorators": "^7.17.8",
11
11
  "@babel/plugin-transform-react-constant-elements": "^7.17.6",
12
12
  "@babel/plugin-transform-runtime": "^7.17.0",
13
- "@babel/preset-env": "^7.16.11",
14
- "@babel/preset-react": "^7.16.7",
15
- "@babel/preset-typescript": "^7.16.7",
13
+ "@babel/preset-env": "^7.20.2",
14
+ "@babel/preset-react": "^7.18.6",
15
+ "@babel/preset-typescript": "^7.21.0",
16
16
  "@bytebrand/car-schema-selectors": "^2.0.7",
17
17
  "@bytebrand/fe-histoslider": "^2.1.3",
18
18
  "@bytebrand/i18n-dictionaries": "^0.7.5",
@@ -23,9 +23,14 @@
23
23
  "@mui/material": "^5.9.0",
24
24
  "@mui/styles": "^5.9.0",
25
25
  "@mui/x-date-pickers": "^5.0.0-beta.1",
26
+ "@testing-library/dom": "^9.0.1",
27
+ "@testing-library/jest-dom": "^5.16.5",
28
+ "@testing-library/react": "^11.2.6",
29
+ "@types/jest": "^29.4.0",
26
30
  "@types/js-cookie": "^2.1.0",
27
31
  "@types/uuid": "^8.3.1",
28
32
  "axios": "^0.24.0",
33
+ "babel-jest": "^26.0.0",
29
34
  "classnames": "2.2.6",
30
35
  "core-js": "2.5.7",
31
36
  "d3-array": "^2.2.0",
@@ -33,6 +38,11 @@
33
38
  "d3-scale": "^2.1.0",
34
39
  "date-fns": "2.29.1",
35
40
  "i18next": "^15.0.4",
41
+ "jest": "^26.0.0",
42
+ "jest-environment-jsdom-sixteen": "^2.0.0",
43
+ "jest-svg-transformer": "^1.0.0",
44
+ "jest-dom": "^4.0.0",
45
+ "jest-transform-stub": "^2.0.0",
36
46
  "js-cookie": "^2.2.0",
37
47
  "moment": "^2.29.1",
38
48
  "moment-range": "^4.0.2",
@@ -46,7 +56,10 @@
46
56
  "react-scroll": "^1.7.13",
47
57
  "react-select": "^3.0.4",
48
58
  "react-slick": "^0.29.0",
59
+ "react-test-renderer": "^18.2.0",
60
+ "react-testing-library": "^8.0.1",
49
61
  "slick-carousel": "1.8.1",
62
+ "ts-jest": "^26.0.0",
50
63
  "uuid": "^8.3.2"
51
64
  },
52
65
  "devDependencies": {
@@ -96,10 +109,11 @@
96
109
  },
97
110
  "scripts": {
98
111
  "storybook": "start-storybook -p 6006",
99
- "test": "echo \"Error: no test specified\" && exit 1",
100
112
  "clean": "rm -rf ./dist/*.*",
101
113
  "build:lib": "yarn clean && webpack --config ./webpack.config.js --progress",
102
- "build:story": "build-storybook"
114
+ "build:story": "build-storybook",
115
+ "test": "jest --watch",
116
+ "test:coverage": "yarn run test -- --coverage --watchAll=false || exit 0"
103
117
  },
104
118
  "author": "Maks Okhmatenko",
105
119
  "license": "UNLICENSED"
package/setupTests.js ADDED
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom/extend-expect';
@@ -37,7 +37,7 @@
37
37
  width: 100%
38
38
 
39
39
  .offerButtonSuccess
40
- background-color: $grassGreen !important
40
+ background-color: $lightGreen !important
41
41
  display: flex !important
42
42
  align-items: center
43
43
  justify-content: center
@@ -539,7 +539,6 @@ export function setUtmParameters() {
539
539
  export const updateCookieList = () => {
540
540
  let cookieConsentList = Object.keys(GOOGLE_BUNDLE_COOKIES);
541
541
  let isHomeGoogleGranted = true; // home page google cookie
542
- let isFBGranted = true;
543
542
  let isHotjarGranted = true;
544
543
  const cookieConfig = JSON.parse(localStorage.getItem('cookieConfig')) || {};
545
544
 
@@ -552,16 +551,17 @@ export const updateCookieList = () => {
552
551
  if (cookieConsentList.includes(cookie)) {
553
552
  cookieConsentList = cookieConsentList.filter(i => i !== cookie); // deny google cookie consent for _gcl_au, _ga, _gid, _gat_UA-31842-13, etc
554
553
  isHomeGoogleGranted = false;
555
- } else if (cookie === '_fbp') { // tslint:disable-line
556
- isFBGranted = false;
557
554
  } else if (cookie === 'hotjar') isHotjarGranted = false;
558
555
  });
559
556
  });
560
557
  // grant google cookies
561
558
  if (typeof window.grantCookieConsent === 'function') window.grantCookieConsent(cookieConsentList);
562
- if (isHomeGoogleGranted && typeof window.allowGoogle === 'function') window.allowGoogle();
563
- // grant FB cookies
564
- if (isFBGranted && typeof window.fbq === 'function') window.fbq('consent', 'grant');
559
+ if (isHomeGoogleGranted && typeof window.allowGoogle === 'function') {
560
+ window.allowGoogle();
561
+ // grant FB cookies
562
+ window.fbq('consent', 'grant');
563
+ }
564
+
565
565
  // grant Hotjar cookies
566
566
  if (isHotjarGranted && typeof window.grantHotjarCookieConsent === 'function') window.grantHotjarCookieConsent();
567
567
  };