Skip to content

Commit

Permalink
Fix tests, convert package to esm
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-ok committed Nov 8, 2023
1 parent e2a44d4 commit 98d0839
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
7 changes: 5 additions & 2 deletions dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;; we start by ignoring node_modules. if you need to consume an OCaml
;; we start by ignoring node_modules. if you need to consume an OCaml
;; project from `node_modules`, this should work:
;; - remove the `dirs` stanza below
;; - add a `(subdir node_modules (dirs only_your_package))`
Expand All @@ -10,4 +10,7 @@
(deps
(alias_rec test))
(action
(run npx jest)))
(setenv
NODE_OPTIONS
--experimental-vm-modules
(run npx jest))))
3 changes: 1 addition & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
export default {
rootDir: "./_build/default/",
testMatch: ["**/*_test.js"],
};

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"type": "module",
"devDependencies": {
"jest": "^26.0.1",
"jest": "^26.5.3",
"@testing-library/jest-dom": "^5.10.0",
"moment": "^2.26.0"
}
Expand Down
10 changes: 5 additions & 5 deletions src/MomentRe.re
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module Duration = {
"as";
};

[@mel.module "moment"]
[@mel.module "moment"] [@mel.scope "default"]
external duration:
(
float,
Expand All @@ -56,10 +56,10 @@ external duration:
Duration.t =
"duration";

[@mel.module "moment"]
[@mel.module "moment"] [@mel.scope "default"]
external durationMillis: float => Duration.t = "duration";

[@mel.module "moment"]
[@mel.module "moment"] [@mel.scope "default"]
external durationFormat: string => Duration.t = "duration";

module Moment = {
Expand Down Expand Up @@ -324,10 +324,10 @@ external momentWithFormats: (string, array(string)) => Moment.t = "default";

[@mel.module "moment"] external momentWithComponents: list(int) => Moment.t = "default";

[@mel.module "moment"]
[@mel.module "moment"] [@mel.scope "default"]
external momentUtcWithFormats: (string, array(string)) => Moment.t = "utc";

[@mel.module "moment"]
[@mel.module "moment"] [@mel.scope "default"]
external momentUtcDefaultFormat: string => Moment.t = "utc";

let momentWithUnix = (timestamp: int) =>
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
(target test)
(alias test)
(libraries melange-moment melange-jest.jest)
(module_systems es6)
(preprocess
(pps melange.ppx)))
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2397,7 +2397,7 @@ jest-worker@^26.6.2:
merge-stream "^2.0.0"
supports-color "^7.0.0"

jest@^26.0.1:
jest@^26.5.3:
version "26.6.3"
resolved "https://registry.yarnpkg.com/jest/-/jest-26.6.3.tgz#40e8fdbe48f00dfa1f0ce8121ca74b88ac9148ef"
integrity sha512-lGS5PXGAzR4RF7V5+XObhqz2KZIDUA1yD0DG6pBVmy10eh0ZIXQImRuzocsI/N2XZ1GrLFwTS27In2i2jlpq1Q==
Expand Down

0 comments on commit 98d0839

Please sign in to comment.