rescript-jest-date-mock 2.0.0 → 2.0.2

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.
Files changed (35) hide show
  1. package/README.md +31 -20
  2. package/lib/bs/.compiler.log +2 -2
  3. package/lib/bs/.sourcedirs.json +1 -1
  4. package/lib/bs/build.ninja +0 -24
  5. package/lib/bs/compiler-info.json +8 -0
  6. package/lib/bs/src/RescriptJestDateMock.ast +0 -0
  7. package/lib/bs/src/RescriptJestDateMock.bs.js +2 -0
  8. package/lib/bs/src/RescriptJestDateMock.cmi +0 -0
  9. package/lib/bs/src/RescriptJestDateMock.cmj +0 -0
  10. package/lib/bs/src/RescriptJestDateMock.cmt +0 -0
  11. package/lib/bs/src/RescriptJestDateMock.res +11 -0
  12. package/lib/ocaml/.compiler.log +2 -0
  13. package/lib/ocaml/RescriptJestDateMock.ast +0 -0
  14. package/lib/ocaml/RescriptJestDateMock.cmi +0 -0
  15. package/lib/ocaml/RescriptJestDateMock.cmj +0 -0
  16. package/lib/ocaml/RescriptJestDateMock.cmt +0 -0
  17. package/lib/ocaml/RescriptJestDateMock.res +11 -0
  18. package/package.json +9 -8
  19. package/{bsconfig.json → rescript.json} +2 -4
  20. package/src/RescriptJestDateMock.res +11 -0
  21. package/.merlin +0 -12
  22. package/lib/bs/.bsbuild +0 -8
  23. package/lib/bs/.bsdeps +0 -6
  24. package/lib/bs/.bsdeps_js +0 -0
  25. package/lib/bs/.ninja_deps +0 -0
  26. package/lib/bs/.ninja_log +0 -26
  27. package/lib/bs/__tests__/JestDateMock_tests.ast +0 -0
  28. package/lib/bs/__tests__/JestDateMock_tests.cmi +0 -0
  29. package/lib/bs/__tests__/JestDateMock_tests.cmj +0 -0
  30. package/lib/bs/__tests__/JestDateMock_tests.cmt +0 -0
  31. package/lib/bs/__tests__/JestDateMock_tests.d +0 -1
  32. package/lib/bs/install.ninja +0 -10
  33. package/lib/bs/src/RescriptJestDateMock.d +0 -0
  34. package/lib/bs/src/RescriptJestDateMock.resast +0 -0
  35. package/src/RescriptJestDateMock.re +0 -11
package/README.md CHANGED
@@ -1,20 +1,19 @@
1
1
  # rescript-jest-date-mock
2
2
 
3
- [![NPM version](http://img.shields.io/npm/v/rescript-jest-date-mock.svg)](https://www.npmjs.org/package/rescript-jest-date-mock)
4
- [![Build Status](https://travis-ci.org/mikaello/rescript-jest-date-mock.svg?branch=master)](https://travis-ci.org/mikaello/rescript-jest-date-mock)
3
+ [![NPM version](https://img.shields.io/npm/v/rescript-jest-date-mock.svg)](https://www.npmjs.org/package/rescript-jest-date-mock)
5
4
 
6
- ReScript bindings for [jest-date-mock](https://github.com/hustcc/jest-date-mock). Use it to mock `Js.Date.t` when using Jest.
5
+ ReScript bindings for [jest-date-mock](https://github.com/hustcc/jest-date-mock). Use it to mock `Date.t` when using Jest.
7
6
 
8
7
  ## Getting started
9
8
 
10
9
  ```
11
- yarn add rescript-jest-date-mock
10
+ npm install rescript-jest-date-mock
12
11
  ```
13
12
 
14
- Then add `rescript-jest-date-mock` as a dependency to `bsconfig.json`:
13
+ Then add `rescript-jest-date-mock` as a dependency to `rescript.json`:
15
14
 
16
15
  ```diff
17
- "bs-dependencies": [
16
+ "dependencies": [
18
17
  + "rescript-jest-date-mock"
19
18
  ]
20
19
  ```
@@ -29,35 +28,47 @@ And add `jest-date-mock` to Jest setup files in `package.json` (you will need to
29
28
  }
30
29
  ```
31
30
 
32
- There is also other ways, check out the [setup sections](https://github.com/hustcc/jest-date-mock#setup) in jest-date-mock.
31
+ For other setup options, see the [jest-date-mock setup guide](https://github.com/hustcc/jest-date-mock#setup).
33
32
 
34
33
  ## Example
35
34
 
36
- ```reason
37
- open BsJestDateMock
35
+ ```rescript
36
+ open RescriptJestDateMock
38
37
 
39
- advanceTo(Js.Date.makeWithYMD(~year=2010.0, ~month=5.0, ~date=27.0, ()));
38
+ advanceTo(Date.makeWithYMDHMS(~year=2010, ~month=5, ~day=27, ~hours=0, ~minutes=0, ~seconds=0))
40
39
 
41
- Js.log(Js.Date.make() |> Js.Date.toUTCString);
42
- // => Sat, 26 Jun 2010 22:00:00 GMT
40
+ Console.log(Date.make()->Date.toUTCString)
41
+ // In Europe/Stockholm: Sat, 26 Jun 2010 22:00:00 GMT
43
42
 
44
- advanceBy(3 * 60 * 1000); // advanceBy 3 minutes (given in milliseconds)
43
+ advanceBy(3 * 60 * 1000) // advanceBy 3 minutes (given in milliseconds)
45
44
 
46
- Js.log(Js.Date.make() |> Js.Date.toUTCString);
47
- // => Sat, 26 Jun 2010 22:03:00 GMT
45
+ Console.log(Date.make()->Date.toUTCString)
46
+ // In Europe/Stockholm: Sat, 26 Jun 2010 22:03:00 GMT
48
47
 
49
- clear(); // shut down mock system, Js.Date should now be as before
48
+ clear() // shut down mock system, Date should now be as before
50
49
 
51
- Js.log(Js.Date.make() |> Js.Date.toUTCString);
52
- // => Sat, 06 Jul 2019 07:01:41 GMT
50
+ // Date now uses the real clock again.
51
+ ```
52
+
53
+ For the same UTC output in every timezone, use an absolute timestamp:
54
+
55
+ ```rescript
56
+ open RescriptJestDateMock
57
+
58
+ advanceTo(Date.fromTime(0.0))
59
+
60
+ Console.log(Date.make()->Date.toUTCString)
61
+ // => Thu, 01 Jan 1970 00:00:00 GMT
62
+
63
+ clear()
53
64
  ```
54
65
 
55
66
  ## Contribute
56
67
 
57
68
  - If you find bugs or want to improve this library, feel free to open an issue or PR.
58
- - If you are upgrading any dependencies, please use yarn so `yarn.lock` is updated.
69
+ - If you upgrade dependencies, use npm and commit the updated `package-lock.json`.
59
70
  - Try to adhere to [Angular commit guidelines](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guideline).
60
71
 
61
72
  ## Alternatives
62
73
 
63
- There is some tips in the post "[Mocking/stubbing the current Date in Jest tests](https://codewithhugo.com/mocking-the-current-date-in-jest-tests/)" by Hugo Di Francesco.
74
+ For more ideas, see "[Mocking/stubbing the current Date in Jest tests](https://codewithhugo.com/mocking-the-current-date-in-jest-tests/)" by Hugo Di Francesco.
@@ -1,2 +1,2 @@
1
- #Start(1609492041107)
2
- #Done(1609492042579)
1
+ #Start(1790339813225)
2
+ #Done(1790339813227)
@@ -1 +1 @@
1
- { "dirs" : [ "__tests__" , "src" ] , "pkgs" : [ [ "@glennsl/bs-jest" , "/Users/mikael/projects/bs-jest-date-mock/node_modules/@glennsl/bs-jest" ] , [ "bs-platform" , "/Users/mikael/projects/bs-jest-date-mock/node_modules/bs-platform" ] ] , "generated" : [] }
1
+ {"cmt_scan":[{"also_scan_build_root":true,"build_root":"lib/bs","scan_dirs":["__tests__","src"]}],"dirs":["__tests__","src"],"generated":[],"pkgs":[["@glennsl/rescript-jest","/workspaces/rescript-jest-date-mock/node_modules/@glennsl/rescript-jest"]],"version":2}
@@ -1,24 +0,0 @@
1
- rescript = 1
2
- g_finger := /Users/mikael/projects/bs-jest-date-mock/node_modules/@glennsl/bs-jest/lib/ocaml/install.stamp
3
- rule astj
4
- command = /Users/mikael/projects/bs-jest-date-mock/node_modules/bs-platform/darwin/bsc.exe -warn-error +101 -bs-v 8.4.2 -absname -bs-ast -o $out $i
5
- o __tests__/JestDateMock_tests.ast : astj ../../__tests__/JestDateMock_tests.res
6
- rule deps_dev
7
- command = /Users/mikael/projects/bs-jest-date-mock/node_modules/bs-platform/darwin/bsb_helper.exe -g -hash e5a649c717f8b02ff34ff5397abb3b8b $in
8
- restat = 1
9
- o __tests__/JestDateMock_tests.d : deps_dev __tests__/JestDateMock_tests.ast
10
- rule mij_dev
11
- command = /Users/mikael/projects/bs-jest-date-mock/node_modules/bs-platform/darwin/bsc.exe -I __tests__ -I src -I /Users/mikael/projects/bs-jest-date-mock/node_modules/@glennsl/bs-jest/lib/ocaml -warn-error +101 -bs-package-name rescript-jest-date-mock -bs-package-output commonjs:$in_d:.bs.js -bs-v $g_finger $i
12
- dyndep = 1
13
- restat = 1
14
- o __tests__/JestDateMock_tests.cmj __tests__/JestDateMock_tests.cmi ../../__tests__/JestDateMock_tests.bs.js : mij_dev __tests__/JestDateMock_tests.ast
15
- o src/RescriptJestDateMock.ast : astj ../../src/RescriptJestDateMock.re
16
- rule deps
17
- command = /Users/mikael/projects/bs-jest-date-mock/node_modules/bs-platform/darwin/bsb_helper.exe -hash e5a649c717f8b02ff34ff5397abb3b8b $in
18
- restat = 1
19
- o src/RescriptJestDateMock.d : deps src/RescriptJestDateMock.ast
20
- rule mij
21
- command = /Users/mikael/projects/bs-jest-date-mock/node_modules/bs-platform/darwin/bsc.exe -I src -I /Users/mikael/projects/bs-jest-date-mock/node_modules/@glennsl/bs-jest/lib/ocaml -warn-error +101 -bs-package-name rescript-jest-date-mock -bs-package-output commonjs:$in_d:.bs.js -bs-v $g_finger $i
22
- dyndep = 1
23
- restat = 1
24
- o src/RescriptJestDateMock.cmj src/RescriptJestDateMock.cmi ../../src/RescriptJestDateMock.bs.js : mij src/RescriptJestDateMock.ast
@@ -0,0 +1,8 @@
1
+ {
2
+ "version": "12.3.1",
3
+ "bsc_path": "/workspaces/rescript-jest-date-mock/node_modules/@rescript/linux-x64/bin/bsc.exe",
4
+ "bsc_hash": "1006241435e8d5052329c523202a7fe6359a37e1e1688c023d37d6a7ebb5fb6d",
5
+ "rescript_config_hash": "2179c76ca380e28ac5df2ae745603bf5224ddd2fc7536b6e7c79fba211421764",
6
+ "runtime_path": "/workspaces/rescript-jest-date-mock/node_modules/@rescript/runtime",
7
+ "generated_at": "1790339813230"
8
+ }
Binary file
@@ -0,0 +1,2 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+ /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
Binary file
Binary file
Binary file
@@ -0,0 +1,11 @@
1
+ /** advance date timestamp by [ms] */
2
+ @module("jest-date-mock")
3
+ external advanceBy: int => unit = "advanceBy"
4
+
5
+ /** reset date to [timestamp] */
6
+ @module("jest-date-mock")
7
+ external advanceTo: Date.t => unit = "advanceTo"
8
+
9
+ /** shut down the mock system */
10
+ @module("jest-date-mock")
11
+ external clear: unit => unit = "clear"
@@ -0,0 +1,2 @@
1
+ #Start(1790339813225)
2
+ #Done(1790339813227)
@@ -0,0 +1,11 @@
1
+ /** advance date timestamp by [ms] */
2
+ @module("jest-date-mock")
3
+ external advanceBy: int => unit = "advanceBy"
4
+
5
+ /** reset date to [timestamp] */
6
+ @module("jest-date-mock")
7
+ external advanceTo: Date.t => unit = "advanceTo"
8
+
9
+ /** shut down the mock system */
10
+ @module("jest-date-mock")
11
+ external clear: unit => unit = "clear"
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "rescript-jest-date-mock",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "scripts": {
5
- "build": "bsb -make-world",
6
- "start": "bsb -make-world -w",
7
- "clean": "bsb -clean-world",
8
- "pretest": "yarn run build",
5
+ "build": "rescript build",
6
+ "start": "rescript build -w",
7
+ "clean": "rescript clean",
8
+ "pretest": "npm run build",
9
9
  "test": "jest"
10
10
  },
11
11
  "keywords": [
@@ -20,13 +20,14 @@
20
20
  "bugs": "https://github.com/mikaello/rescript-jest-date-mock/issues",
21
21
  "license": "MIT",
22
22
  "devDependencies": {
23
- "@glennsl/bs-jest": "^0.6.0",
24
- "bs-platform": "^8.4.2"
23
+ "@glennsl/rescript-jest": "0.13.1",
24
+ "rescript": "12.3.1"
25
25
  },
26
26
  "dependencies": {
27
- "jest-date-mock": "^1.0.8"
27
+ "jest-date-mock": "1.0.10"
28
28
  },
29
29
  "jest": {
30
+ "testPathIgnorePatterns": ["/lib/"],
30
31
  "setupFiles": [
31
32
  "jest-date-mock"
32
33
  ]
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "name": "rescript-jest-date-mock",
3
- "version": "0.1.0",
4
3
  "sources": [
5
4
  {
6
5
  "dir": "src",
@@ -16,10 +15,9 @@
16
15
  "in-source": true
17
16
  },
18
17
  "suffix": ".bs.js",
19
- "bs-dependencies": ["@glennsl/bs-jest"],
18
+ "dev-dependencies": ["@glennsl/rescript-jest"],
20
19
  "warnings": {
21
20
  "error": "+101"
22
21
  },
23
- "namespace": false,
24
- "refmt": 3
22
+ "namespace": false
25
23
  }
@@ -0,0 +1,11 @@
1
+ /** advance date timestamp by [ms] */
2
+ @module("jest-date-mock")
3
+ external advanceBy: int => unit = "advanceBy"
4
+
5
+ /** reset date to [timestamp] */
6
+ @module("jest-date-mock")
7
+ external advanceTo: Date.t => unit = "advanceTo"
8
+
9
+ /** shut down the mock system */
10
+ @module("jest-date-mock")
11
+ external clear: unit => unit = "clear"
package/.merlin DELETED
@@ -1,12 +0,0 @@
1
- ####{BSB GENERATED: NO EDIT
2
- FLG -ppx '/Users/mikael/projects/bs-jest-date-mock/node_modules/bs-platform/darwin/bsc.exe -as-ppx '
3
- S /Users/mikael/projects/bs-jest-date-mock/node_modules/bs-platform/lib/ocaml
4
- B /Users/mikael/projects/bs-jest-date-mock/node_modules/bs-platform/lib/ocaml
5
- FLG -w +a-4-9-20-40-41-42-50-61-102
6
- S /Users/mikael/projects/bs-jest-date-mock/node_modules/@glennsl/bs-jest/lib/ocaml
7
- B /Users/mikael/projects/bs-jest-date-mock/node_modules/@glennsl/bs-jest/lib/ocaml
8
- S __tests__
9
- B lib/bs/__tests__
10
- S src
11
- B lib/bs/src
12
- ####BSB GENERATED: NO EDIT}
package/lib/bs/.bsbuild DELETED
@@ -1,8 +0,0 @@
1
- 1
2
- RescriptJestDateMock
3
- src
4
- 1
5
- 1
6
- JestDateMock_tests
7
- __tests__
8
- 1
package/lib/bs/.bsdeps DELETED
@@ -1,6 +0,0 @@
1
- 8.4.2
2
- /Users/mikael/projects/bs-jest-date-mock
3
- 0
4
- bsconfig.json 0x1.7fb7d86901b5bp+30
5
- __tests__ 0x1.7fb7db74c4f84p+30
6
- src 0x1.7fbb911830c7dp+30
package/lib/bs/.bsdeps_js DELETED
Binary file
Binary file
package/lib/bs/.ninja_log DELETED
@@ -1,26 +0,0 @@
1
- # ninja log v6
2
- 1 25 1609430734810153302 __tests__/JestDateMock_tests.resast 54de60824e6ed628
3
- 22 72 1609430700753287961 /Users/mikael/projects/bs-jest-date-mock/src/RescriptJestDateMock.bs.js b58fd50f3a7ba9c8
4
- 22 72 1609430700753287961 src/RescriptJestDateMock.cmi b58fd50f3a7ba9c8
5
- 22 72 1609430700753287961 src/RescriptJestDateMock.cmj b58fd50f3a7ba9c8
6
- 1 34 1609430678556149211 src/RescriptJestDateMock.reast 3694ab841586a5b5
7
- 1 21 1609430700701100405 src/RescriptJestDateMock.d 6cc0639acaf834ee
8
- 1 8 1609430678531500957 __tests__/Test.d e5a443ddd532b0d7
9
- 1 14 1609430520315689600 __tests__/Test.resast 755a72e0623508e4
10
- 0 36 1609430734810153302 /Users/mikael/projects/bs-jest-date-mock/__tests__/JestDateMock_tests.bs.js a499319f477ed122
11
- 0 36 1609430734810153302 __tests__/JestDateMock_tests.cmi a499319f477ed122
12
- 0 36 1609430734810153302 __tests__/JestDateMock_tests.cmj a499319f477ed122
13
- 25 32 1609430734810153302 __tests__/JestDateMock_tests.d e5b086f0318fd1b0
14
- 1 9 1609429038658489533 src/BsJestDateMock.d de348b1d244d9e2c
15
- 1 35 1609430678557460570 __tests__/JestDateMock_tests.reast 376115981e993ce5
16
- 4 386 1609429038658489533 src/BsJestDateMock.reast 11dd821aa189e74e
17
- 0 36 1609492041129388077 __tests__/JestDateMock_tests.ast a6549320d73d63d2
18
- 36 61 1609492041129388077 __tests__/JestDateMock_tests.d e8313af8871a56f5
19
- 2 414 1609492041519753419 src/RescriptJestDateMock.ast b02062446f522c2b
20
- 414 427 1609492041519753419 src/RescriptJestDateMock.d 7c5eaab90d2c8dbc
21
- 427 466 1609492041571454886 src/RescriptJestDateMock.cmj 81d82b2157393830
22
- 427 466 1609492041571454886 src/RescriptJestDateMock.cmi 81d82b2157393830
23
- 427 466 1609492041571454886 ../../src/RescriptJestDateMock.bs.js 81d82b2157393830
24
- 466 510 1609492041616142592 __tests__/JestDateMock_tests.cmj 54c12a1cf59d65c7
25
- 466 510 1609492041616142592 __tests__/JestDateMock_tests.cmi 54c12a1cf59d65c7
26
- 466 510 1609492041616142592 ../../__tests__/JestDateMock_tests.bs.js 54c12a1cf59d65c7
@@ -1 +0,0 @@
1
- __tests__/JestDateMock_tests.cmj : src/RescriptJestDateMock.cmj src/RescriptJestDateMock.cmi
@@ -1,10 +0,0 @@
1
- rescript = 1
2
- rule cp
3
- command = cp $i $out
4
- rule touch
5
- command = touch $out
6
- o RescriptJestDateMock.cmi : cp ../bs/src/RescriptJestDateMock.cmi
7
- o RescriptJestDateMock.cmj : cp ../bs/src/RescriptJestDateMock.cmj
8
- o RescriptJestDateMock.cmt : cp ../bs/src/RescriptJestDateMock.cmt
9
- o RescriptJestDateMock.re : cp ../../src/RescriptJestDateMock.re
10
- build install.stamp : touch RescriptJestDateMock.cmi RescriptJestDateMock.cmj
File without changes
@@ -1,11 +0,0 @@
1
- /** advance date timestamp by [ms] */
2
- [@bs.module "jest-date-mock"]
3
- external advanceBy: int => unit = "advanceBy";
4
-
5
- /** reset date to [timestamp] */
6
- [@bs.module "jest-date-mock"]
7
- external advanceTo: Js.Date.t => unit = "advanceTo";
8
-
9
- /** shut down the mock system */
10
- [@bs.module "jest-date-mock"]
11
- external clear: unit => unit = "clear";