From 9656b8c577839d39bc52049bb7e2f19999ec388f Mon Sep 17 00:00:00 2001
From: Sebastian Malton
Date: Wed, 19 Apr 2023 14:26:47 -0400
Subject: [PATCH] chore: Fix unit tests by increasing coverage of tooltip to
100%
Signed-off-by: Sebastian Malton
---
package-lock.json | 24 +-
packages/ui-components/tooltip/jest.config.js | 12 +-
packages/ui-components/tooltip/package.json | 8 +-
.../src/__snapshots__/tooltip.test.tsx.snap | 194 ++++++++++
.../__snapshots__/withTooltip.test.tsx.snap | 41 +++
packages/ui-components/tooltip/src/helpers.ts | 141 +++++++
.../tooltip/src/tooltip.test.tsx | 344 +++++++++++++++++-
.../ui-components/tooltip/src/tooltip.tsx | 114 +-----
.../tooltip/src/withTooltip.test.tsx | 45 +++
.../ui-components/tooltip/src/withTooltip.tsx | 2 -
10 files changed, 807 insertions(+), 118 deletions(-)
create mode 100644 packages/ui-components/tooltip/src/__snapshots__/withTooltip.test.tsx.snap
create mode 100644 packages/ui-components/tooltip/src/helpers.ts
create mode 100644 packages/ui-components/tooltip/src/withTooltip.test.tsx
diff --git a/package-lock.json b/package-lock.json
index ec217c22a0..b5b98bf3a3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -36730,14 +36730,12 @@
"devDependencies": {
"@async-fn/jest": "^1.6.4",
"@k8slens/eslint-config": "6.5.0-alpha.1",
- "@k8slens/react-testing-library-discovery": "^1.0.0-alpha.0"
+ "@k8slens/react-testing-library-discovery": "^1.0.0-alpha.0",
+ "@testing-library/react": "^12.1.5",
+ "@testing-library/user-event": "^12.8.3"
},
"peerDependencies": {
- "@k8slens/feature-core": "^6.5.0-alpha.0",
"@k8slens/utilities": "^1.0.0-alpha.1",
- "@ogre-tools/fp": "^15.1.2",
- "@ogre-tools/injectable": "^15.1.2",
- "@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
"auto-bind": "^4.0.0",
"lodash": "^4.17.21",
"mobx": "^6.8.0",
@@ -36774,6 +36772,22 @@
"prettier": ">= 2"
}
},
+ "packages/ui-components/tooltip/node_modules/@testing-library/user-event": {
+ "version": "12.8.3",
+ "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-12.8.3.tgz",
+ "integrity": "sha512-IR0iWbFkgd56Bu5ZI/ej8yQwrkCv8Qydx6RzwbKz9faXazR/+5tvYKsZQgyXJiwgpcva127YO6JcWy7YlCfofQ==",
+ "dev": true,
+ "dependencies": {
+ "@babel/runtime": "^7.12.5"
+ },
+ "engines": {
+ "node": ">=10",
+ "npm": ">=6"
+ },
+ "peerDependencies": {
+ "@testing-library/dom": ">=7.21.4"
+ }
+ },
"packages/utility-features/react-testing-library-discovery": {
"name": "@k8slens/react-testing-library-discovery",
"version": "1.0.0-alpha.3",
diff --git a/packages/ui-components/tooltip/jest.config.js b/packages/ui-components/tooltip/jest.config.js
index 1013f3076d..05ec7ecd4d 100644
--- a/packages/ui-components/tooltip/jest.config.js
+++ b/packages/ui-components/tooltip/jest.config.js
@@ -1,13 +1,3 @@
const { configForReact } = require("@k8slens/jest").monorepoPackageConfig(__dirname);
-module.exports = {
- ...configForReact,
- coverageThreshold: {
- global: {
- statements: 84,
- branches: 67,
- lines: 84,
- functions: 92,
- },
- },
-};
+module.exports = configForReact;
diff --git a/packages/ui-components/tooltip/package.json b/packages/ui-components/tooltip/package.json
index ebe465a1e2..6cdbd776d9 100644
--- a/packages/ui-components/tooltip/package.json
+++ b/packages/ui-components/tooltip/package.json
@@ -30,11 +30,7 @@
"lint:fix": "lens-lint --fix"
},
"peerDependencies": {
- "@k8slens/feature-core": "^6.5.0-alpha.0",
"@k8slens/utilities": "^1.0.0-alpha.1",
- "@ogre-tools/injectable": "^15.1.2",
- "@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
- "@ogre-tools/fp": "^15.1.2",
"auto-bind": "^4.0.0",
"lodash": "^4.17.21",
"mobx": "^6.8.0",
@@ -45,6 +41,8 @@
"devDependencies": {
"@async-fn/jest": "^1.6.4",
"@k8slens/eslint-config": "6.5.0-alpha.1",
- "@k8slens/react-testing-library-discovery": "^1.0.0-alpha.0"
+ "@k8slens/react-testing-library-discovery": "^1.0.0-alpha.0",
+ "@testing-library/react": "^12.1.5",
+ "@testing-library/user-event": "^12.8.3"
}
}
diff --git a/packages/ui-components/tooltip/src/__snapshots__/tooltip.test.tsx.snap b/packages/ui-components/tooltip/src/__snapshots__/tooltip.test.tsx.snap
index 76c7911fa9..babbf9d0cf 100644
--- a/packages/ui-components/tooltip/src/__snapshots__/tooltip.test.tsx.snap
+++ b/packages/ui-components/tooltip/src/__snapshots__/tooltip.test.tsx.snap
@@ -17,6 +17,7 @@ exports[` renders to DOM when forced to by visible prop 1`] = `
+
+
+ I am a tooltip
+
+
+
+
+
+
+
+
+ I am a tooltip
+
+
+
+
+
+
+
+
+ I am a tooltip
+
+
+
+
+
+
+ I am a tooltip
+
+
+
+
+
+
+
+
+
+
+
+