@serenity-js/assertions 3.10.4 → 3.11.1

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/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.11.1](https://github.com/serenity-js/serenity-js/compare/v3.11.0...v3.11.1) (2023-10-04)
7
+
8
+ **Note:** Version bump only for package @serenity-js/assertions
9
+
10
+
11
+
12
+
13
+
14
+ # [3.11.0](https://github.com/serenity-js/serenity-js/compare/v3.10.4...v3.11.0) (2023-10-03)
15
+
16
+
17
+ ### Features
18
+
19
+ * **assertions:** isBefore and isAfter accept Timestamp as well as Date objects ([55e13d0](https://github.com/serenity-js/serenity-js/commit/55e13d00a447c0ec70dd496fb7948f171977a682))
20
+
21
+
22
+
23
+
24
+
6
25
  ## [3.10.4](https://github.com/serenity-js/serenity-js/compare/v3.10.3...v3.10.4) (2023-09-22)
7
26
 
8
27
  **Note:** Version bump only for package @serenity-js/assertions
@@ -1,4 +1,4 @@
1
- import { Expectation } from '@serenity-js/core';
1
+ import { Expectation, type Timestamp } from '@serenity-js/core';
2
2
  /**
3
3
  * Creates an {@apilink Expectation|expectation} that is met when the actual value of type `Date`
4
4
  * is after the expected `Date`.
@@ -38,5 +38,5 @@ import { Expectation } from '@serenity-js/core';
38
38
  *
39
39
  * @group Expectations
40
40
  */
41
- export declare const isAfter: (expected: import("@serenity-js/core").Answerable<Date>) => Expectation<Date>;
41
+ export declare const isAfter: (expected: import("@serenity-js/core").Answerable<Date | Timestamp>) => Expectation<Date | Timestamp>;
42
42
  //# sourceMappingURL=isAfter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isAfter.d.ts","sourceRoot":"","sources":["../../src/expectations/isAfter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,OAAO,+EAInB,CAAC"}
1
+ {"version":3,"file":"isAfter.d.ts","sourceRoot":"","sources":["../../src/expectations/isAfter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,OAAO,uGAanB,CAAC"}
@@ -41,5 +41,13 @@ const core_1 = require("@serenity-js/core");
41
41
  *
42
42
  * @group Expectations
43
43
  */
44
- exports.isAfter = core_1.Expectation.define('isAfter', 'have value that is after', (actual, expected) => actual.getTime() > expected.getTime());
44
+ exports.isAfter = core_1.Expectation.define('isAfter', 'have value that is after', (actual, expected) => {
45
+ const actualInMilliseconds = actual instanceof Date
46
+ ? actual.getTime()
47
+ : actual.toMilliseconds();
48
+ const expectedInMilliseconds = expected instanceof Date
49
+ ? expected.getTime()
50
+ : expected.toMilliseconds();
51
+ return actualInMilliseconds > expectedInMilliseconds;
52
+ });
45
53
  //# sourceMappingURL=isAfter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"isAfter.js","sourceRoot":"","sources":["../../src/expectations/isAfter.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACU,QAAA,OAAO,GAAG,kBAAW,CAAC,MAAM,CACrC,SAAS,EAAE,0BAA0B,EACrC,CAAC,MAAY,EAAE,QAAc,EAAE,EAAE,CAC7B,MAAM,CAAC,OAAO,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,CAC5C,CAAC"}
1
+ {"version":3,"file":"isAfter.js","sourceRoot":"","sources":["../../src/expectations/isAfter.ts"],"names":[],"mappings":";;;AAAA,4CAAgE;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACU,QAAA,OAAO,GAAG,kBAAW,CAAC,MAAM,CACrC,SAAS,EAAE,0BAA0B,EACrC,CAAC,MAAwB,EAAE,QAA0B,EAAE,EAAE;IACrD,MAAM,oBAAoB,GAAG,MAAM,YAAY,IAAI;QAC/C,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE;QAClB,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;IAE9B,MAAM,sBAAsB,GAAG,QAAQ,YAAY,IAAI;QACnD,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE;QACpB,CAAC,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;IAEhC,OAAO,oBAAoB,GAAG,sBAAsB,CAAC;AACzD,CAAC,CACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Expectation } from '@serenity-js/core';
1
+ import { Expectation, type Timestamp } from '@serenity-js/core';
2
2
  /**
3
3
  * Creates an {@apilink Expectation|expectation} that is met when the actual value of type `Date`
4
4
  * is before the expected `Date`.
@@ -38,5 +38,5 @@ import { Expectation } from '@serenity-js/core';
38
38
  *
39
39
  * @group Expectations
40
40
  */
41
- export declare const isBefore: (expected: import("@serenity-js/core").Answerable<Date>) => Expectation<Date>;
41
+ export declare const isBefore: (expected: import("@serenity-js/core").Answerable<Date | Timestamp>) => Expectation<Date | Timestamp>;
42
42
  //# sourceMappingURL=isBefore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isBefore.d.ts","sourceRoot":"","sources":["../../src/expectations/isBefore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,QAAQ,+EAIpB,CAAC"}
1
+ {"version":3,"file":"isBefore.d.ts","sourceRoot":"","sources":["../../src/expectations/isBefore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,QAAQ,uGAcpB,CAAC"}
@@ -41,5 +41,13 @@ const core_1 = require("@serenity-js/core");
41
41
  *
42
42
  * @group Expectations
43
43
  */
44
- exports.isBefore = core_1.Expectation.define('isBefore', 'have value that is before', (actual, expected) => actual.getTime() < expected.getTime());
44
+ exports.isBefore = core_1.Expectation.define('isBefore', 'have value that is before', (actual, expected) => {
45
+ const actualInMilliseconds = actual instanceof Date
46
+ ? actual.getTime()
47
+ : actual.toMilliseconds();
48
+ const expectedInMilliseconds = expected instanceof Date
49
+ ? expected.getTime()
50
+ : expected.toMilliseconds();
51
+ return actualInMilliseconds < expectedInMilliseconds;
52
+ });
45
53
  //# sourceMappingURL=isBefore.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"isBefore.js","sourceRoot":"","sources":["../../src/expectations/isBefore.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACU,QAAA,QAAQ,GAAG,kBAAW,CAAC,MAAM,CACtC,UAAU,EAAE,2BAA2B,EACvC,CAAC,MAAY,EAAE,QAAc,EAAE,EAAE,CAC7B,MAAM,CAAC,OAAO,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,CAC5C,CAAC"}
1
+ {"version":3,"file":"isBefore.js","sourceRoot":"","sources":["../../src/expectations/isBefore.ts"],"names":[],"mappings":";;;AAAA,4CAAgE;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACU,QAAA,QAAQ,GAAG,kBAAW,CAAC,MAAM,CACtC,UAAU,EAAE,2BAA2B,EACvC,CAAC,MAAwB,EAAE,QAA0B,EAAE,EAAE;IAErD,MAAM,oBAAoB,GAAG,MAAM,YAAY,IAAI;QAC/C,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE;QAClB,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;IAE9B,MAAM,sBAAsB,GAAG,QAAQ,YAAY,IAAI;QACnD,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE;QACpB,CAAC,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;IAEhC,OAAO,oBAAoB,GAAG,sBAAsB,CAAC;AACzD,CAAC,CACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serenity-js/assertions",
3
- "version": "3.10.4",
3
+ "version": "3.11.1",
4
4
  "description": "Screenplay-style assertion library",
5
5
  "author": {
6
6
  "name": "Jan Molak",
@@ -43,18 +43,18 @@
43
43
  "node": "^16.13 || ^18.12 || ^20"
44
44
  },
45
45
  "dependencies": {
46
- "@serenity-js/core": "3.10.4",
46
+ "@serenity-js/core": "3.11.1",
47
47
  "tiny-types": "^1.20.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@integration/testing-tools": "3.0.0",
51
51
  "@types/chai": "^4.3.6",
52
- "@types/mocha": "^10.0.1",
52
+ "@types/mocha": "^10.0.2",
53
53
  "c8": "8.0.1",
54
54
  "mocha": "^10.2.0",
55
55
  "mocha-multi": "^1.1.7",
56
56
  "ts-node": "^10.9.1",
57
57
  "typescript": "5.1.6"
58
58
  },
59
- "gitHead": "28f12bd6029a9a6c1d8e492486138bf0c83916cd"
59
+ "gitHead": "b3e36f6e42eb2c545afa961946469fb6dd93f4df"
60
60
  }
@@ -1,4 +1,4 @@
1
- import { Expectation } from '@serenity-js/core';
1
+ import { Expectation, type Timestamp } from '@serenity-js/core';
2
2
 
3
3
  /**
4
4
  * Creates an {@apilink Expectation|expectation} that is met when the actual value of type `Date`
@@ -41,6 +41,15 @@ import { Expectation } from '@serenity-js/core';
41
41
  */
42
42
  export const isAfter = Expectation.define(
43
43
  'isAfter', 'have value that is after',
44
- (actual: Date, expected: Date) =>
45
- actual.getTime() > expected.getTime()
44
+ (actual: Date | Timestamp, expected: Date | Timestamp) => {
45
+ const actualInMilliseconds = actual instanceof Date
46
+ ? actual.getTime()
47
+ : actual.toMilliseconds();
48
+
49
+ const expectedInMilliseconds = expected instanceof Date
50
+ ? expected.getTime()
51
+ : expected.toMilliseconds();
52
+
53
+ return actualInMilliseconds > expectedInMilliseconds;
54
+ }
46
55
  );
@@ -1,4 +1,4 @@
1
- import { Expectation } from '@serenity-js/core';
1
+ import { Expectation, type Timestamp } from '@serenity-js/core';
2
2
 
3
3
  /**
4
4
  * Creates an {@apilink Expectation|expectation} that is met when the actual value of type `Date`
@@ -41,6 +41,16 @@ import { Expectation } from '@serenity-js/core';
41
41
  */
42
42
  export const isBefore = Expectation.define(
43
43
  'isBefore', 'have value that is before',
44
- (actual: Date, expected: Date) =>
45
- actual.getTime() < expected.getTime()
44
+ (actual: Date | Timestamp, expected: Date | Timestamp) => {
45
+
46
+ const actualInMilliseconds = actual instanceof Date
47
+ ? actual.getTime()
48
+ : actual.toMilliseconds();
49
+
50
+ const expectedInMilliseconds = expected instanceof Date
51
+ ? expected.getTime()
52
+ : expected.toMilliseconds();
53
+
54
+ return actualInMilliseconds < expectedInMilliseconds;
55
+ }
46
56
  );