@tapjs/asserts
Advanced tools
Comparing version 0.0.0-9 to 0.0.0-10
@@ -1,2 +0,2 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" resolution-mode="require"/> | ||
import { Extra, MessageExtra, TapPlugin, TestBase } from '@tapjs/core'; | ||
@@ -117,2 +117,29 @@ import EventEmitter from 'events'; | ||
/** | ||
* Verify that the value matches the pattern provided, with no | ||
* extra properties. | ||
*/ | ||
matchOnlyStrict(found: any, wanted: any, ...[msg, extra]: MessageExtra): boolean; | ||
/** | ||
* Verify that the value does not match the pattern provided, with no | ||
* extra properties. Ie, it might either not match, or have extra props. | ||
*/ | ||
notMatchOnlyStrict(found: any, doNotWant: any, ...[msg, extra]: MessageExtra): boolean; | ||
/** | ||
* Verify that the value matches the pattern provided, but fail if any | ||
* fields *only* match via type coercion. | ||
* | ||
* For example, | ||
* | ||
* ```ts | ||
* t.matchStrict({ a: 1 }, { a: Number }, 'this passes') | ||
* t.matchStrict({ a: 1 }, { a: '1' }, 'this fails') | ||
* ``` | ||
*/ | ||
matchStrict(found: any, wanted: any, ...[msg, extra]: MessageExtra): boolean; | ||
/** | ||
* Verify that the value does not match the pattern provided, without | ||
* type coercion. | ||
*/ | ||
notMatchStrict(found: any, doNotWant: any, ...[msg, extra]: MessageExtra): boolean; | ||
/** | ||
* Verify that the object has the wanted property, anywhere in its | ||
@@ -119,0 +146,0 @@ * prototype chain. |
@@ -362,2 +362,65 @@ "use strict"; | ||
/** | ||
* Verify that the value matches the pattern provided, with no | ||
* extra properties. | ||
*/ | ||
matchOnlyStrict(found, wanted, ...[msg, extra]) { | ||
// this.#t.currentAssert = this.#t.t.matchOnlyStrict | ||
const args = [msg, extra]; | ||
const me = (0, core_1.normalizeMessageExtra)('should match pattern', args); | ||
const { match: ok, diff } = (0, tcompare_1.matchOnlyStrict)(found, wanted, this.#opts); | ||
if (ok) | ||
return this.#t.pass(...me); | ||
Object.assign(me[1], { diff }); | ||
return this.#t.fail(...me); | ||
} | ||
/** | ||
* Verify that the value does not match the pattern provided, with no | ||
* extra properties. Ie, it might either not match, or have extra props. | ||
*/ | ||
notMatchOnlyStrict(found, doNotWant, ...[msg, extra]) { | ||
// this.#t.currentAssert = this.#t.t.notMatchOnlyStrict | ||
const args = [msg, extra]; | ||
const me = (0, core_1.normalizeMessageExtra)('should not match pattern', args); | ||
const { match: ok } = (0, tcompare_1.matchOnlyStrict)(found, doNotWant, this.#opts); | ||
if (!ok) | ||
return this.#t.pass(...me); | ||
Object.assign(me[1], { found, doNotWant }); | ||
return this.#t.fail(...me); | ||
} | ||
/** | ||
* Verify that the value matches the pattern provided, but fail if any | ||
* fields *only* match via type coercion. | ||
* | ||
* For example, | ||
* | ||
* ```ts | ||
* t.matchStrict({ a: 1 }, { a: Number }, 'this passes') | ||
* t.matchStrict({ a: 1 }, { a: '1' }, 'this fails') | ||
* ``` | ||
*/ | ||
matchStrict(found, wanted, ...[msg, extra]) { | ||
this.#t.currentAssert = this.#t.t.matchStrict; | ||
const args = [msg, extra]; | ||
const me = (0, core_1.normalizeMessageExtra)('should match pattern', args); | ||
const { match: ok, diff } = (0, tcompare_1.matchStrict)(found, wanted, this.#opts); | ||
if (ok) | ||
return this.#t.pass(...me); | ||
Object.assign(me[1], { diff }); | ||
return this.#t.fail(...me); | ||
} | ||
/** | ||
* Verify that the value does not match the pattern provided, without | ||
* type coercion. | ||
*/ | ||
notMatchStrict(found, doNotWant, ...[msg, extra]) { | ||
this.#t.currentAssert = this.#t.t.notMatchStrict; | ||
const args = [msg, extra]; | ||
const me = (0, core_1.normalizeMessageExtra)('should not match pattern', args); | ||
const { match: ok } = (0, tcompare_1.matchStrict)(found, doNotWant, this.#opts); | ||
if (!ok) | ||
return this.#t.pass(...me); | ||
Object.assign(me[1], { found, doNotWant }); | ||
return this.#t.fail(...me); | ||
} | ||
/** | ||
* Verify that the object has the wanted property, anywhere in its | ||
@@ -364,0 +427,0 @@ * prototype chain. |
@@ -1,2 +0,2 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" resolution-mode="require"/> | ||
import { Extra, MessageExtra, TapPlugin, TestBase } from '@tapjs/core'; | ||
@@ -117,2 +117,29 @@ import EventEmitter from 'events'; | ||
/** | ||
* Verify that the value matches the pattern provided, with no | ||
* extra properties. | ||
*/ | ||
matchOnlyStrict(found: any, wanted: any, ...[msg, extra]: MessageExtra): boolean; | ||
/** | ||
* Verify that the value does not match the pattern provided, with no | ||
* extra properties. Ie, it might either not match, or have extra props. | ||
*/ | ||
notMatchOnlyStrict(found: any, doNotWant: any, ...[msg, extra]: MessageExtra): boolean; | ||
/** | ||
* Verify that the value matches the pattern provided, but fail if any | ||
* fields *only* match via type coercion. | ||
* | ||
* For example, | ||
* | ||
* ```ts | ||
* t.matchStrict({ a: 1 }, { a: Number }, 'this passes') | ||
* t.matchStrict({ a: 1 }, { a: '1' }, 'this fails') | ||
* ``` | ||
*/ | ||
matchStrict(found: any, wanted: any, ...[msg, extra]: MessageExtra): boolean; | ||
/** | ||
* Verify that the value does not match the pattern provided, without | ||
* type coercion. | ||
*/ | ||
notMatchStrict(found: any, doNotWant: any, ...[msg, extra]: MessageExtra): boolean; | ||
/** | ||
* Verify that the object has the wanted property, anywhere in its | ||
@@ -119,0 +146,0 @@ * prototype chain. |
@@ -5,3 +5,3 @@ import { normalizeMessageExtra, } from '@tapjs/core'; | ||
import { isPromise } from 'is-actual-promise'; | ||
import { has, hasStrict, match, matchOnly, same, strict, } from 'tcompare'; | ||
import { has, hasStrict, match, matchOnly, matchOnlyStrict, matchStrict, same, strict, } from 'tcompare'; | ||
import { Deferred } from 'trivial-deferred'; | ||
@@ -334,2 +334,65 @@ import { normalizeThrowsArgs } from './normalize-throws-args.js'; | ||
/** | ||
* Verify that the value matches the pattern provided, with no | ||
* extra properties. | ||
*/ | ||
matchOnlyStrict(found, wanted, ...[msg, extra]) { | ||
// this.#t.currentAssert = this.#t.t.matchOnlyStrict | ||
const args = [msg, extra]; | ||
const me = normalizeMessageExtra('should match pattern', args); | ||
const { match: ok, diff } = matchOnlyStrict(found, wanted, this.#opts); | ||
if (ok) | ||
return this.#t.pass(...me); | ||
Object.assign(me[1], { diff }); | ||
return this.#t.fail(...me); | ||
} | ||
/** | ||
* Verify that the value does not match the pattern provided, with no | ||
* extra properties. Ie, it might either not match, or have extra props. | ||
*/ | ||
notMatchOnlyStrict(found, doNotWant, ...[msg, extra]) { | ||
// this.#t.currentAssert = this.#t.t.notMatchOnlyStrict | ||
const args = [msg, extra]; | ||
const me = normalizeMessageExtra('should not match pattern', args); | ||
const { match: ok } = matchOnlyStrict(found, doNotWant, this.#opts); | ||
if (!ok) | ||
return this.#t.pass(...me); | ||
Object.assign(me[1], { found, doNotWant }); | ||
return this.#t.fail(...me); | ||
} | ||
/** | ||
* Verify that the value matches the pattern provided, but fail if any | ||
* fields *only* match via type coercion. | ||
* | ||
* For example, | ||
* | ||
* ```ts | ||
* t.matchStrict({ a: 1 }, { a: Number }, 'this passes') | ||
* t.matchStrict({ a: 1 }, { a: '1' }, 'this fails') | ||
* ``` | ||
*/ | ||
matchStrict(found, wanted, ...[msg, extra]) { | ||
this.#t.currentAssert = this.#t.t.matchStrict; | ||
const args = [msg, extra]; | ||
const me = normalizeMessageExtra('should match pattern', args); | ||
const { match: ok, diff } = matchStrict(found, wanted, this.#opts); | ||
if (ok) | ||
return this.#t.pass(...me); | ||
Object.assign(me[1], { diff }); | ||
return this.#t.fail(...me); | ||
} | ||
/** | ||
* Verify that the value does not match the pattern provided, without | ||
* type coercion. | ||
*/ | ||
notMatchStrict(found, doNotWant, ...[msg, extra]) { | ||
this.#t.currentAssert = this.#t.t.notMatchStrict; | ||
const args = [msg, extra]; | ||
const me = normalizeMessageExtra('should not match pattern', args); | ||
const { match: ok } = matchStrict(found, doNotWant, this.#opts); | ||
if (!ok) | ||
return this.#t.pass(...me); | ||
Object.assign(me[1], { found, doNotWant }); | ||
return this.#t.fail(...me); | ||
} | ||
/** | ||
* Verify that the object has the wanted property, anywhere in its | ||
@@ -336,0 +399,0 @@ * prototype chain. |
{ | ||
"name": "@tapjs/asserts", | ||
"version": "0.0.0-9", | ||
"version": "0.0.0-10", | ||
"description": "", | ||
"author": "Isaac Z. Schlueter <i@izs.me> (https://blog.izs.me)", | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/mjs/index.js", | ||
"type": "module", | ||
"exports": { | ||
@@ -41,7 +40,7 @@ "./package.json": { | ||
"peerDependencies": { | ||
"@tapjs/core": "0.0.0-9" | ||
"@tapjs/core": "0.0.0-10" | ||
}, | ||
"dependencies": { | ||
"is-actual-promise": "^1.0.0", | ||
"tcompare": "6.0.1-1", | ||
"tcompare": "6.0.1-2", | ||
"trivial-deferred": "^2.0.0" | ||
@@ -48,0 +47,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
208779
1971
Yes
+ Added@tapjs/core@0.0.0-10(transitive)
+ Added@tapjs/stack@0.0.0-3(transitive)
+ Added@tapjs/test@0.0.0-10(transitive)
+ Addedcross-spawn@7.0.5(transitive)
+ Addedtap-parser@15.0.0-1(transitive)
+ Addedtcompare@6.0.1-2(transitive)
- Removed@tapjs/core@0.0.0-9(transitive)
- Removed@tapjs/stack@0.0.0-2(transitive)
- Removed@tapjs/test@0.0.0-9(transitive)
- Removedcross-spawn@7.0.3(transitive)
- Removedtap-parser@15.0.0-0(transitive)
- Removedtcompare@6.0.1-1(transitive)
Updatedtcompare@6.0.1-2