From c43f5b2b0116217a1bb010ec9943d611dc25addd Mon Sep 17 00:00:00 2001 From: "M.D. van Es" Date: Sat, 19 Jun 2021 20:19:39 +0200 Subject: [PATCH] Tests need commonjs --- packages/dockerlist-client/.bsb.lock | 1 - .../__tests__/DockerUtil.test.bs.js | 8 +- packages/dockerlist-client/bsconfig.json | 2 +- packages/dockerlist-client/package.json | 2 +- packages/dockerlist-client/src/Dialog.bs.js | 18 +- .../dockerlist-client/src/DockerApi.bs.js | 18 +- .../src/DockerApiReason.bs.js | 14 +- .../dockerlist-client/src/DockerList.bs.js | 28 +- .../src/DockerListItem.bs.js | 24 +- .../dockerlist-client/src/DockerUtil.bs.js | 22 +- .../__snapshots__/DockerList.test.tsx.snap | 331 +++++++++--------- .../dockerlist-client/webpack.config.prod.js | 46 --- 12 files changed, 227 insertions(+), 287 deletions(-) delete mode 100644 packages/dockerlist-client/.bsb.lock delete mode 100644 packages/dockerlist-client/webpack.config.prod.js diff --git a/packages/dockerlist-client/.bsb.lock b/packages/dockerlist-client/.bsb.lock deleted file mode 100644 index 2c2bced..0000000 --- a/packages/dockerlist-client/.bsb.lock +++ /dev/null @@ -1 +0,0 @@ -28603 \ No newline at end of file diff --git a/packages/dockerlist-client/__tests__/DockerUtil.test.bs.js b/packages/dockerlist-client/__tests__/DockerUtil.test.bs.js index 5bb7a6d..98158dc 100644 --- a/packages/dockerlist-client/__tests__/DockerUtil.test.bs.js +++ b/packages/dockerlist-client/__tests__/DockerUtil.test.bs.js @@ -1,7 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; -import * as Jest from "@glennsl/bs-jest/src/jest.bs.js"; -import * as DockerUtil$MdworldHomeremoteDockerlist from "../src/DockerUtil.bs.js"; +var Jest = require("@glennsl/bs-jest/src/jest.bs.js"); +var DockerUtil$MdworldHomeremoteDockerlist = require("../src/DockerUtil.bs.js"); Jest.describe("DockerUtil", (function (param) { Jest.test("toClassName skips disabled classes", (function (param) { @@ -28,7 +29,4 @@ Jest.describe("DockerUtil", (function (param) { })); })); -export { - -} /* Not a pure module */ diff --git a/packages/dockerlist-client/bsconfig.json b/packages/dockerlist-client/bsconfig.json index 7d4cfb5..0372a73 100644 --- a/packages/dockerlist-client/bsconfig.json +++ b/packages/dockerlist-client/bsconfig.json @@ -12,7 +12,7 @@ ], "package-specs": [ { - "module": "es6", + "module": "commonjs", "in-source": true } ], diff --git a/packages/dockerlist-client/package.json b/packages/dockerlist-client/package.json index 502a623..c5c1333 100644 --- a/packages/dockerlist-client/package.json +++ b/packages/dockerlist-client/package.json @@ -9,7 +9,7 @@ }, "scripts": { "clean": "rm src/*.bs.js && rm src/*.gen.tsx", - "build": "yarn re:build && webpack-cli --config webpack.config.prod.js && tsc src/DockerList.gen.tsx --outDir lib -d", + "build": "yarn re:build", "re:build": "rescript", "re:start": "rescript build -w" }, diff --git a/packages/dockerlist-client/src/Dialog.bs.js b/packages/dockerlist-client/src/Dialog.bs.js index daa7208..a12905b 100644 --- a/packages/dockerlist-client/src/Dialog.bs.js +++ b/packages/dockerlist-client/src/Dialog.bs.js @@ -1,9 +1,10 @@ // Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; -import * as Curry from "rescript/lib/es6/curry.js"; -import * as React from "react"; -import * as Core from "@material-ui/core"; -import * as DockerListModuleCss from "./DockerList.module.css"; +var Curry = require("rescript/lib/js/curry.js"); +var React = require("react"); +var Core = require("@material-ui/core"); +var DockerListModuleCss = require("./DockerList.module.css"); var styles = DockerListModuleCss; @@ -63,10 +64,7 @@ function Dialog(Props) { var make = Dialog; -export { - styles , - getDialog , - make , - -} +exports.styles = styles; +exports.getDialog = getDialog; +exports.make = make; /* styles Not a pure module */ diff --git a/packages/dockerlist-client/src/DockerApi.bs.js b/packages/dockerlist-client/src/DockerApi.bs.js index 9af8244..e67c25e 100644 --- a/packages/dockerlist-client/src/DockerApi.bs.js +++ b/packages/dockerlist-client/src/DockerApi.bs.js @@ -1,7 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; -import * as Curry from "rescript/lib/es6/curry.js"; -import * as Js_exn from "rescript/lib/es6/js_exn.js"; +var Curry = require("rescript/lib/js/curry.js"); +var Js_exn = require("rescript/lib/js/js_exn.js"); function handleResponse(promise, onError, errorMessage) { var __x = promise.then(function (jsonResponse) { @@ -71,12 +72,9 @@ function toggleContainerStateCreator(setContainers, url, onError, setIsLoading) }; } -export { - handleResponse , - getDockerList , - startContainer , - stopContainer , - toggleContainerStateCreator , - -} +exports.handleResponse = handleResponse; +exports.getDockerList = getDockerList; +exports.startContainer = startContainer; +exports.stopContainer = stopContainer; +exports.toggleContainerStateCreator = toggleContainerStateCreator; /* No side effect */ diff --git a/packages/dockerlist-client/src/DockerApiReason.bs.js b/packages/dockerlist-client/src/DockerApiReason.bs.js index d0ab68f..d3dcb16 100644 --- a/packages/dockerlist-client/src/DockerApiReason.bs.js +++ b/packages/dockerlist-client/src/DockerApiReason.bs.js @@ -1,7 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; -import * as Curry from "rescript/lib/es6/curry.js"; -import * as Js_exn from "rescript/lib/es6/js_exn.js"; +var Curry = require("rescript/lib/js/curry.js"); +var Js_exn = require("rescript/lib/js/js_exn.js"); function getDockerList(url, onError) { return fetch(url + "/api/dockerlist").then(function (response) { @@ -48,10 +49,7 @@ function stopContainer(url, id, onError) { }); } -export { - getDockerList , - startContainer , - stopContainer , - -} +exports.getDockerList = getDockerList; +exports.startContainer = startContainer; +exports.stopContainer = stopContainer; /* No side effect */ diff --git a/packages/dockerlist-client/src/DockerList.bs.js b/packages/dockerlist-client/src/DockerList.bs.js index 7aa289b..d5d17f9 100644 --- a/packages/dockerlist-client/src/DockerList.bs.js +++ b/packages/dockerlist-client/src/DockerList.bs.js @@ -1,14 +1,15 @@ // Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; -import * as Curry from "rescript/lib/es6/curry.js"; -import * as React from "react"; -import * as MaterialUi_Box from "@jsiebern/bs-material-ui/src/MaterialUi_Box.bs.js"; -import * as MaterialUi_Grid from "@jsiebern/bs-material-ui/src/MaterialUi_Grid.bs.js"; -import * as Core from "@material-ui/core"; -import * as Dialog$MdworldHomeremoteDockerlist from "./Dialog.bs.js"; -import * as DockerApi$MdworldHomeremoteDockerlist from "./DockerApi.bs.js"; -import * as DockerUtil$MdworldHomeremoteDockerlist from "./DockerUtil.bs.js"; -import * as DockerListItem$MdworldHomeremoteDockerlist from "./DockerListItem.bs.js"; +var Curry = require("rescript/lib/js/curry.js"); +var React = require("react"); +var MaterialUi_Box = require("@jsiebern/bs-material-ui/src/MaterialUi_Box.bs.js"); +var MaterialUi_Grid = require("@jsiebern/bs-material-ui/src/MaterialUi_Grid.bs.js"); +var Core = require("@material-ui/core"); +var Dialog$MdworldHomeremoteDockerlist = require("./Dialog.bs.js"); +var DockerApi$MdworldHomeremoteDockerlist = require("./DockerApi.bs.js"); +var DockerUtil$MdworldHomeremoteDockerlist = require("./DockerUtil.bs.js"); +var DockerListItem$MdworldHomeremoteDockerlist = require("./DockerListItem.bs.js"); function renderAsItem(setSelectedContainer, dockerContainer) { return React.createElement(DockerListItem$MdworldHomeremoteDockerlist.make, { @@ -109,10 +110,7 @@ var DockerListMod = { make: DockerList$DockerListMod }; -export { - renderAsItem , - renderListCreator , - DockerListMod , - -} +exports.renderAsItem = renderAsItem; +exports.renderListCreator = renderListCreator; +exports.DockerListMod = DockerListMod; /* react Not a pure module */ diff --git a/packages/dockerlist-client/src/DockerListItem.bs.js b/packages/dockerlist-client/src/DockerListItem.bs.js index 3e64715..572a11a 100644 --- a/packages/dockerlist-client/src/DockerListItem.bs.js +++ b/packages/dockerlist-client/src/DockerListItem.bs.js @@ -1,12 +1,13 @@ // Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; -import * as Curry from "rescript/lib/es6/curry.js"; -import * as React from "react"; -import * as Core from "@material-ui/core"; -import * as MaterialUi_Checkbox from "@jsiebern/bs-material-ui/src/MaterialUi_Checkbox.bs.js"; -import * as MaterialUi_IconButton from "@jsiebern/bs-material-ui/src/MaterialUi_IconButton.bs.js"; -import * as DockerListModuleCss from "./DockerList.module.css"; -import $$Error from "@material-ui/icons/Error"; +var Curry = require("rescript/lib/js/curry.js"); +var React = require("react"); +var Core = require("@material-ui/core"); +var MaterialUi_Checkbox = require("@jsiebern/bs-material-ui/src/MaterialUi_Checkbox.bs.js"); +var MaterialUi_IconButton = require("@jsiebern/bs-material-ui/src/MaterialUi_IconButton.bs.js"); +var DockerListModuleCss = require("./DockerList.module.css"); +var $$Error = require("@material-ui/icons/Error").default; var styles = DockerListModuleCss; @@ -57,10 +58,7 @@ function DockerListItem(Props) { var make = DockerListItem; -export { - styles , - ErrorIcon , - make , - -} +exports.styles = styles; +exports.ErrorIcon = ErrorIcon; +exports.make = make; /* styles Not a pure module */ diff --git a/packages/dockerlist-client/src/DockerUtil.bs.js b/packages/dockerlist-client/src/DockerUtil.bs.js index ff99c52..340e664 100644 --- a/packages/dockerlist-client/src/DockerUtil.bs.js +++ b/packages/dockerlist-client/src/DockerUtil.bs.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; -import * as Caml_array from "rescript/lib/es6/caml_array.js"; +var Caml_array = require("rescript/lib/js/caml_array.js"); function toClassName0(input) { return input.filter(function (param) { @@ -80,15 +81,12 @@ function compareDockerContainer(c1, c2) { } } -export { - toClassName0 , - testResult0 , - test0 , - toClassName1 , - testResult1 , - test1 , - toClassName , - compareDockerContainer , - -} +exports.toClassName0 = toClassName0; +exports.testResult0 = testResult0; +exports.test0 = test0; +exports.toClassName1 = toClassName1; +exports.testResult1 = testResult1; +exports.test1 = test1; +exports.toClassName = toClassName; +exports.compareDockerContainer = compareDockerContainer; /* testResult0 Not a pure module */ diff --git a/packages/dockerlist-client/src/__snapshots__/DockerList.test.tsx.snap b/packages/dockerlist-client/src/__snapshots__/DockerList.test.tsx.snap index c7c07ec..bd3f980 100644 --- a/packages/dockerlist-client/src/__snapshots__/DockerList.test.tsx.snap +++ b/packages/dockerlist-client/src/__snapshots__/DockerList.test.tsx.snap @@ -2,211 +2,212 @@ exports[`DockerList client renders buttons for each docker container: container 1`] = `
-
-
    +
    -
    -
    +
      + class="MuiBox-root MuiBox-root-7" + /> +
      - - - + + + +
      +
      - -
      -
      + class="MuiTypography-root MuiListItemText-primary MuiTypography-body2 MuiTypography-displayBlock" + > + determined_edison + +

      + Up 2 days +

      +
      - determined_edison - -

      - Up 2 days -

      + class="MuiTouchRipple-root" + />
      -
      -
      -
      -
    -
      +
    +
    -
    -
    +
      + class="MuiBox-root MuiBox-root-2" + /> +
      - - - + + + +
      +
      - -
      -
      + class="MuiTypography-root MuiListItemText-primary MuiTypography-body2 MuiTypography-displayBlock" + > + hello_world + +

      + Exited (0) 17 hours ago +

      +
      - hello_world - -

      - Exited (0) 17 hours ago -

      + class="MuiTouchRipple-root" + />
      -
      -
      -
      -
      -
      +
      - - - + + + +
      +
      - -
      -
      + class="MuiTypography-root MuiListItemText-primary MuiTypography-body2 MuiTypography-displayBlock" + > + tinycors + +

      + Exited (2) 13 hours ago +

      +
      - tinycors - -

      - Exited (2) 13 hours ago -

      + class="MuiTouchRipple-root" + />
      -
      -
      -
      -
    +
+
`; diff --git a/packages/dockerlist-client/webpack.config.prod.js b/packages/dockerlist-client/webpack.config.prod.js deleted file mode 100644 index 4994c1d..0000000 --- a/packages/dockerlist-client/webpack.config.prod.js +++ /dev/null @@ -1,46 +0,0 @@ -const path = require("path"); -const TerserPlugin = require("terser-webpack-plugin"); - -process.env.BABEL_ENV = "production"; -process.env.NODE_ENV = "production"; - -module.exports = { - mode: "production", - entry: "./src/DockerList.bs.js", - output: { - path: path.resolve(__dirname, "lib"), - filename: "DockerList.bs.js", - libraryTarget: "commonjs2", - }, - module: { - rules: [ - { - test: /\.(js|jsx)$/, - include: path.resolve(__dirname, "src"), - exclude: /(node_modules|bower_components|build)/, - use: { - loader: "babel-loader", - options: { - presets: ["@babel/preset-env", "@babel/preset-react"], - }, - }, - }, - { test: /\.css$/, loader: "style-loader!css-loader" }, - { test: /\.svg$/, loader: "url-loader" }, - ], - }, - externals: { - react: "commonjs react", - }, - optimization: { - minimize: true, - minimizer: [ - new TerserPlugin({ - terserOptions: { - // Default is to write cache dirs in /packages/*/node_modules/.cache - nameCache: {}, - }, - }), - ], - }, -};