From 245c6a4e0cbf47ce37fbc89a1f846976d100272f Mon Sep 17 00:00:00 2001 From: Michael Stauffer Date: Mon, 15 Mar 2021 15:52:00 -0400 Subject: [PATCH 1/8] Working on FileUpload unit tests. Several new ones added --- lab/webapp/package-lock.json | 28 + lab/webapp/package.json | 2 + .../__snapshots__/fileUpload.test.js.snap | 550 ++++++++++++++++++ .../components/FileUpload/fileUpload.test.js | 271 ++++++--- lab/webapp/src/components/FileUpload/index.js | 27 +- tests/unit/js_tests.sh | 2 + 6 files changed, 797 insertions(+), 83 deletions(-) create mode 100644 lab/webapp/src/components/FileUpload/__snapshots__/fileUpload.test.js.snap diff --git a/lab/webapp/package-lock.json b/lab/webapp/package-lock.json index 3ca5d0863..b6e5e8c45 100644 --- a/lab/webapp/package-lock.json +++ b/lab/webapp/package-lock.json @@ -4281,6 +4281,15 @@ "@babel/types": "^7.3.0" } }, + "@types/cheerio": { + "version": "0.22.24", + "resolved": "https://registry.npmjs.org/@types/cheerio/-/cheerio-0.22.24.tgz", + "integrity": "sha512-iKXt/cwltGvN06Dd6zwQG1U35edPwId9lmcSeYfcxSNvvNg4vysnFB+iBQNjj06tSVV7MBj0GWMQ7dwb4Z+p8Q==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/color-name": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", @@ -7644,6 +7653,25 @@ "object-is": "^1.0.2" } }, + "enzyme-to-json": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/enzyme-to-json/-/enzyme-to-json-3.6.1.tgz", + "integrity": "sha512-15tXuONeq5ORoZjV/bUo2gbtZrN2IH+Z6DvL35QmZyKHgbY1ahn6wcnLd9Xv9OjiwbAXiiP8MRZwbZrCv1wYNg==", + "dev": true, + "requires": { + "@types/cheerio": "^0.22.22", + "lodash": "^4.17.15", + "react-is": "^16.12.0" + }, + "dependencies": { + "react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true + } + } + }, "errno": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", diff --git a/lab/webapp/package.json b/lab/webapp/package.json index 944d228f4..801e009ea 100644 --- a/lab/webapp/package.json +++ b/lab/webapp/package.json @@ -53,6 +53,7 @@ "clean-webpack-plugin": "^3.0.0", "enzyme": "^3.11.0", "enzyme-adapter-react-16": "^1.15.2", + "enzyme-to-json": "^3.6.1", "fetch-mock": "^7.7.3", "html-webpack-plugin": "^3.2.0", "html-webpack-template": "^6.2.0", @@ -71,6 +72,7 @@ "webpack-merge": "^4.2.2" }, "jest": { + "snapshotSerializers": ["enzyme-to-json/serializer"], "transform": { "^.+\\.jsx?$": "babel-jest", "^.+\\.js?$": "babel-jest", diff --git a/lab/webapp/src/components/FileUpload/__snapshots__/fileUpload.test.js.snap b/lab/webapp/src/components/FileUpload/__snapshots__/fileUpload.test.js.snap new file mode 100644 index 000000000..969531ac4 --- /dev/null +++ b/lab/webapp/src/components/FileUpload/__snapshots__/fileUpload.test.js.snap @@ -0,0 +1,550 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`basic testing of fileupload react component full component snapshot 1`] = ` +
+ +
+ + + + + + + + +
+
+ +
+ Feature Specification +
+
+ + + + + + + +

+ + The column that describes the label or output for each row. + For example, if analyzing a dataset of patients with different types of diabetes, + this column may have the values "type1", "type2", or "none". + +

+
+ } + disabled={false} + eventsEnabled={true} + header="Dependent Column Help" + offset={0} + on="click" + pinned={false} + position="right center" + trigger={ + + } + /> + + + + + + +

+ + Classification + + algorithms are used to model discrete categorical outputs. Examples include modeling the color car someone might buy ("red", "green", "blue"...) or a disease state ("type1Diabetes", "type2Diabetes", "none"...) +
+
+ + Regression + + algorithms are used to model a continuous valued output. Examples include modeling the amount of money a house is predicted to sell for. +

+
+ } + disabled={false} + eventsEnabled={true} + header="Prediction Type Help" + offset={0} + on="click" + pinned={false} + position="left center" + trigger={ + + } + /> + + + + +
+ + + + + + Set Ordinal + + } + > + + Ordinal Feature Input + + +

+ For each ordinal feature, enter one comma-separated line with the following format (this overrides selections in the Dataset Preview): +
+  [feature name],[1st unique value],[2nd unique value],... +

+

+ For example: +
+  month,jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec +
+  day,mon,tue,wed,thu,fri,sat,sun +

+

+ To populate this text box with all features and their unique values, close this window and use the button to set all feature types as ordinal. +

+
+
+ +