From 9985ad13f2b9cfbc25e0a68ce27753c39ac67c26 Mon Sep 17 00:00:00 2001 From: Devin Ivy Date: Sun, 1 May 2022 14:32:28 -0400 Subject: [PATCH 01/10] Update deps for node v18 support, remove CI reference to old branch --- .github/workflows/ci-module.yml | 1 - package.json | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-module.yml b/.github/workflows/ci-module.yml index 18ea44f..54426ca 100644 --- a/.github/workflows/ci-module.yml +++ b/.github/workflows/ci-module.yml @@ -3,7 +3,6 @@ name: ci on: push: branches: - - v9 - master pull_request: workflow_dispatch: diff --git a/package.json b/package.json index 8f9acdf..573a084 100755 --- a/package.json +++ b/package.json @@ -19,11 +19,11 @@ ] }, "dependencies": { - "@hapi/hoek": "9.x.x" + "@hapi/hoek": "10.x.x" }, "devDependencies": { "@hapi/eslint-plugin": "*", - "@hapi/lab": "25.0.0-beta.0", + "@hapi/lab": "25.0.0-beta.1", "@types/node": "^17.0.25", "typescript": "~4.6.3" }, From 1dda95a8aafe668b0d19274e576a870805d394d6 Mon Sep 17 00:00:00 2001 From: devin ivy Date: Sun, 1 May 2022 15:21:51 -0400 Subject: [PATCH 02/10] Fix license years for Sideway versus contributors (#176) --- LICENSE.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index 82fe1b1..244fd32 100755 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,5 @@ -Copyright (c) 2014-2022, Sideway Inc, and project contributors +Copyright (c) 2014-2022, Project contributors +Copyright (c) 2014-2020, Sideway Inc Copyright (c) 2014, Walmart Copyright (c) 2011-2014 Jake Luer All rights reserved. From a4ab995a4372fec067778ba1666e9c71ccfd9218 Mon Sep 17 00:00:00 2001 From: Devin Ivy Date: Sun, 1 May 2022 16:10:43 -0400 Subject: [PATCH 03/10] 9.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 573a084..6a3ba7b 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@hapi/code", "description": "assertion library", - "version": "8.0.7", + "version": "9.0.0", "repository": "git://github.com/hapijs/code", "main": "lib/index.js", "types": "lib/index.d.ts", From 02ee6bbf66797790b3c3e8793aed581031df6aaf Mon Sep 17 00:00:00 2001 From: Ari Bolton Date: Tue, 14 Jun 2022 08:39:43 -0700 Subject: [PATCH 04/10] Fix `reject()` types (#177) * Fix types * Update tests * Update docs * Update lab * Remove redundant await's Co-authored-by: Gil Pedersen --- API.md | 2 +- lib/index.d.ts | 20 ++++++++++---------- package.json | 2 +- test/index.ts | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/API.md b/API.md index cb39273..7f0f1fb 100755 --- a/API.md +++ b/API.md @@ -625,7 +625,7 @@ and compared to the provided optional requirements where: - `message` a string or regular expression matching the rejected error `message` property. Note that a string must provide a full match. -Returns the rejected error object. +Returns a promise resolving to the rejected error object. ```js const NodeUtil = require('util'); diff --git a/lib/index.d.ts b/lib/index.d.ts index 4759610..026b97b 100755 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -616,10 +616,10 @@ declare namespace expect { * @param type - constructor function the error must be an instance of. * @param message - string or regular expression the error message must match. * - * @returns rejected value. + * @returns a promise resolving to the rejected value. */ - reject(type: Class, message?: string | RegExp): E; - reject(message?: string | RegExp): E; + reject(type: Class, message?: string | RegExp): Promise; + reject(message?: string | RegExp): Promise; /** * Asserts that the Promise reference value rejects with an exception when called. @@ -627,10 +627,10 @@ declare namespace expect { * @param type - constructor function the error must be an instance of. * @param message - string or regular expression the error message must match. * - * @returns rejected value. + * @returns a promise resolving to the rejected value. */ - rejects(type: Class, message?: string | RegExp): E; - rejects(message?: string | RegExp): E; + rejects(type: Class, message?: string | RegExp): Promise; + rejects(message?: string | RegExp): Promise; } interface Not_PromiseAssertion extends BaseAssertion { @@ -638,15 +638,15 @@ declare namespace expect { /** * Asserts that the Promise reference value rejects with an exception when called. * - * @returns null. + * @returns a promise resolving to null. */ - reject(): null; + reject(): Promise; /** * Asserts that the Promise reference value rejects with an exception when called. * - * @returns null. + * @returns a promise resolving to null. */ - rejects(): null; + rejects(): Promise; } } diff --git a/package.json b/package.json index 6a3ba7b..756dd93 100755 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "devDependencies": { "@hapi/eslint-plugin": "*", - "@hapi/lab": "25.0.0-beta.1", + "@hapi/lab": "^25.0.1", "@types/node": "^17.0.25", "typescript": "~4.6.3" }, diff --git a/test/index.ts b/test/index.ts index d756dd2..12e9476 100755 --- a/test/index.ts +++ b/test/index.ts @@ -186,8 +186,8 @@ Code.expect(type2).to.equal({ a: [1] }, { skip: ['c'] }); const rejection = Promise.reject(new Error('Oh no!')); -await expect.type>(Code.expect(rejection).to.reject('Oh no!')); -await expect.type>(Code.expect(rejection).rejects('Oh no!')); +expect.type>(Code.expect(rejection).to.reject('Oh no!')); +expect.type>(Code.expect(rejection).rejects('Oh no!')); class CustomError extends Error { } @@ -200,10 +200,10 @@ Code.expect(throws).to.throw(CustomError, 'Oh no!'); Code.expect(() => { }).to.not.throw().and.to.be.a.function(); const typedRejection = Promise.reject(new CustomError('Oh no!')); -await expect.type(Code.expect(typedRejection).to.reject(CustomError, 'Oh no!')); -await expect.type(Code.expect(typedRejection).rejects(CustomError, 'Oh no!')); +expect.type>(Code.expect(typedRejection).to.reject(CustomError, 'Oh no!')); +expect.type>(Code.expect(typedRejection).rejects(CustomError, 'Oh no!')); -await expect.type(Code.expect(Promise.resolve(true)).to.not.reject()); +expect.type>(Code.expect(Promise.resolve(true)).to.not.reject()); function foo(): number | undefined { return 123; From aa1f2b36bcdd56d69f876af5d1e2b114807c80d2 Mon Sep 17 00:00:00 2001 From: Devin Ivy Date: Tue, 14 Jun 2022 11:40:21 -0400 Subject: [PATCH 05/10] 9.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 756dd93..31c6989 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@hapi/code", "description": "assertion library", - "version": "9.0.0", + "version": "9.0.1", "repository": "git://github.com/hapijs/code", "main": "lib/index.js", "types": "lib/index.d.ts", From b4ffcec5880a463ac2f4fb06097c943a9787fa63 Mon Sep 17 00:00:00 2001 From: Eran Hammer Date: Tue, 29 Nov 2022 09:37:58 +0100 Subject: [PATCH 06/10] Fix typo and add missing type (#178) * Fix typo * Add missing about assertion * Update lib/index.d.ts Co-authored-by: Jonas Pauthier Co-authored-by: Jonas Pauthier --- lib/index.d.ts | 10 ++++++++++ lib/index.js | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/index.d.ts b/lib/index.d.ts index 026b97b..f9de592 100755 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -504,6 +504,16 @@ declare namespace expect { */ above(value: T): Assertion; + /** + * Asserts that the reference value is within a delta difference from the provided value. + * + * @param value - the value to compare to. + * @param delta - the delta +/- range value. + * + * @returns assertion chain object. + */ + about(value: T, delta: number): Assertion; + /** * Asserts that the reference value is greater than (>) the provided value. * diff --git a/lib/index.js b/lib/index.js index a456866..cd20268 100755 --- a/lib/index.js +++ b/lib/index.js @@ -356,7 +356,7 @@ internals.between = function (from, to) { internals.addMethod('between', internals.between); -internals.above = function (value, delta) { +internals.about = function (value, delta) { internals.assert(this, internals.type(this._ref) === 'number', 'Can only assert about on numbers'); internals.assert(this, internals.type(value) === 'number' && internals.type(delta) === 'number', 'About assertion requires two number arguments'); @@ -364,7 +364,7 @@ internals.above = function (value, delta) { return this.assert(Math.abs(this._ref - value) <= delta, 'be about ' + value + ' \u00b1' + delta); }; -internals.addMethod('about', internals.above); +internals.addMethod('about', internals.about); internals.instanceof = function (type) { From 0de76047dcf4b6875872879204d0547d4a684fd3 Mon Sep 17 00:00:00 2001 From: Nargonath Date: Tue, 29 Nov 2022 09:46:15 +0100 Subject: [PATCH 07/10] 9.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 31c6989..718c3c1 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@hapi/code", "description": "assertion library", - "version": "9.0.1", + "version": "9.0.2", "repository": "git://github.com/hapijs/code", "main": "lib/index.js", "types": "lib/index.d.ts", From 63dbf43b55065a1fd15ea9e3b57e7ed7ea1cc465 Mon Sep 17 00:00:00 2001 From: Nicolas Morel Date: Sat, 11 Feb 2023 19:00:46 +0100 Subject: [PATCH 08/10] chore: bump hoek (#179) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 718c3c1..fa0a0c9 100755 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ ] }, "dependencies": { - "@hapi/hoek": "10.x.x" + "@hapi/hoek": "^11.0.2" }, "devDependencies": { "@hapi/eslint-plugin": "*", From 425043e302090e541f569ee37d8dd4c0444a9cf4 Mon Sep 17 00:00:00 2001 From: Nicolas Morel Date: Sat, 11 Feb 2023 19:01:14 +0100 Subject: [PATCH 09/10] 9.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fa0a0c9..9fd3a78 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@hapi/code", "description": "assertion library", - "version": "9.0.2", + "version": "9.0.3", "repository": "git://github.com/hapijs/code", "main": "lib/index.js", "types": "lib/index.d.ts", From b1b39c033f8109da62db1221b209153f9a59ce36 Mon Sep 17 00:00:00 2001 From: Nicolas Morel Date: Wed, 23 Oct 2024 17:37:38 +0200 Subject: [PATCH 10/10] chore: pin eslint-plugin --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9fd3a78..5ed5047 100755 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@hapi/hoek": "^11.0.2" }, "devDependencies": { - "@hapi/eslint-plugin": "*", + "@hapi/eslint-plugin": "^6.0.0", "@hapi/lab": "^25.0.1", "@types/node": "^17.0.25", "typescript": "~4.6.3"