rescript-jest-date-mock 2.0.1 → 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.
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.com/mikaello/rescript-jest-date-mock.svg?branch=master)](https://travis-ci.com/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
35
+ ```rescript
37
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(1654233909691)
2
- #Done(1654233909691)
1
+ #Start(1790339813225)
2
+ #Done(1790339813227)
@@ -1 +1 @@
1
- { "dirs" : [ "__tests__" , "src" ] , "pkgs" : [ [ "@glennsl/rescript-jest" , "/workspaces/rescript-jest-date-mock/node_modules/@glennsl/rescript-jest" ] ] , "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 := /workspaces/rescript-jest-date-mock/node_modules/@glennsl/rescript-jest/lib/ocaml/install.stamp
3
- rule astj
4
- command = /workspaces/rescript-jest-date-mock/node_modules/rescript/linux/bsc.exe -warn-error +101 -bs-v 9.1.4 -absname -bs-ast -o $out $i
5
- o __tests__/JestDateMock_tests.ast : astj ../../__tests__/JestDateMock_tests.res
6
- rule deps_dev
7
- command = /workspaces/rescript-jest-date-mock/node_modules/rescript/linux/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 = /workspaces/rescript-jest-date-mock/node_modules/rescript/linux/bsc.exe -I __tests__ -I src -I /workspaces/rescript-jest-date-mock/node_modules/@glennsl/rescript-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 = /workspaces/rescript-jest-date-mock/node_modules/rescript/linux/bsb_helper.exe -hash e5a649c717f8b02ff34ff5397abb3b8b $in
18
- restat = 1
19
- o src/RescriptJestDateMock.d : deps src/RescriptJestDateMock.ast
20
- rule mij
21
- command = /workspaces/rescript-jest-date-mock/node_modules/rescript/linux/bsc.exe -I src -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,6 +1,6 @@
1
1
  {
2
2
  "name": "rescript-jest-date-mock",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "scripts": {
5
5
  "build": "rescript build",
6
6
  "start": "rescript build -w",
@@ -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/rescript-jest": "0.9.1",
24
- "rescript": "9.1.4"
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,7 +15,7 @@
16
15
  "in-source": true
17
16
  },
18
17
  "suffix": ".bs.js",
19
- "bs-dev-dependencies": ["@glennsl/rescript-jest"],
18
+ "dev-dependencies": ["@glennsl/rescript-jest"],
20
19
  "warnings": {
21
20
  "error": "+101"
22
21
  },
@@ -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 '/workspaces/rescript-jest-date-mock/node_modules/rescript/linux/bsc.exe -as-ppx '
3
- S /workspaces/rescript-jest-date-mock/node_modules/rescript/lib/ocaml
4
- B /workspaces/rescript-jest-date-mock/node_modules/rescript/lib/ocaml
5
- FLG -w +a-4-9-20-40-41-42-50-61-102
6
- S /workspaces/rescript-jest-date-mock/node_modules/@glennsl/rescript-jest/lib/ocaml
7
- B /workspaces/rescript-jest-date-mock/node_modules/@glennsl/rescript-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,8 +0,0 @@
1
- 9.1.4
2
- /workspaces/rescript-jest-date-mock
3
- 0
4
- bsconfig.json 0x1.8a666bb3e6332p+30
5
- __tests__ 0x1.8a666c145d6ffp+30
6
- src 0x1.8a666c1451262p+30
7
- ===
8
- /workspaces/rescript-jest-date-mock/node_modules/rescript/linux/rescript.exe 0x1.8a666cd6bc919p+30
package/lib/bs/.ninja_log DELETED
@@ -1,11 +0,0 @@
1
- # ninja log v6
2
- 0 6 1654233861059246651 __tests__/JestDateMock_tests.ast c08b00a1cc9c2e3f
3
- 6 8 1654233861063246723 __tests__/JestDateMock_tests.d 3a6325374613458e
4
- 0 15 1654233861071246867 src/RescriptJestDateMock.ast d04e007e46050520
5
- 15 17 1654233861071246867 src/RescriptJestDateMock.d 59ef9e8c2da4e619
6
- 17 26 1654233861079247012 src/RescriptJestDateMock.cmj dc837d48e03b5a2
7
- 17 26 1654233861079247012 src/RescriptJestDateMock.cmi dc837d48e03b5a2
8
- 17 26 1654233861079247012 ../../src/RescriptJestDateMock.bs.js dc837d48e03b5a2
9
- 26 37 1654233861091247228 __tests__/JestDateMock_tests.cmj 86b9b3160c2318c7
10
- 26 37 1654233861091247228 __tests__/JestDateMock_tests.cmi 86b9b3160c2318c7
11
- 26 37 1654233861091247228 ../../__tests__/JestDateMock_tests.bs.js 86b9b3160c2318c7
@@ -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
package/renovate.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "extends": [
3
- "config:base"
4
- ]
5
- }
@@ -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";