hein 2.0.0-alpha.1 → 2.0.0-alpha.3
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/dist/_virtual/rolldown_runtime.cjs +34 -0
- package/dist/assert/deep-equal.cjs +40 -0
- package/dist/assert/deep-equal.cjs.map +1 -0
- package/dist/assert/deep-equal.d.cts +5 -0
- package/dist/assert/deep-equal.d.cts.map +1 -0
- package/dist/assert/deep-equal.d.ts +5 -0
- package/dist/assert/deep-equal.d.ts.map +1 -0
- package/dist/assert/deep-equal.js +36 -0
- package/dist/assert/deep-equal.js.map +1 -0
- package/dist/assert/deep-has-property.cjs +68 -0
- package/dist/assert/deep-has-property.cjs.map +1 -0
- package/dist/assert/deep-has-property.d.cts +22 -0
- package/dist/assert/deep-has-property.d.cts.map +1 -0
- package/dist/assert/deep-has-property.d.ts +22 -0
- package/dist/assert/deep-has-property.d.ts.map +1 -0
- package/dist/assert/deep-has-property.js +63 -0
- package/dist/assert/deep-has-property.js.map +1 -0
- package/dist/assert/ends-with.cjs +30 -0
- package/dist/assert/ends-with.cjs.map +1 -0
- package/dist/assert/ends-with.d.cts +13 -0
- package/dist/assert/ends-with.d.cts.map +1 -0
- package/dist/assert/ends-with.d.ts +13 -0
- package/dist/assert/ends-with.d.ts.map +1 -0
- package/dist/assert/ends-with.js +27 -0
- package/dist/assert/ends-with.js.map +1 -0
- package/dist/assert/equal.cjs +37 -0
- package/dist/assert/equal.cjs.map +1 -0
- package/dist/assert/equal.d.cts +11 -0
- package/dist/assert/equal.d.cts.map +1 -0
- package/dist/assert/equal.d.ts +11 -0
- package/dist/assert/equal.d.ts.map +1 -0
- package/dist/assert/equal.js +34 -0
- package/dist/assert/equal.js.map +1 -0
- package/dist/assert/greater-than-equal.cjs +32 -0
- package/dist/assert/greater-than-equal.cjs.map +1 -0
- package/dist/assert/greater-than-equal.d.cts +11 -0
- package/dist/assert/greater-than-equal.d.cts.map +1 -0
- package/dist/assert/greater-than-equal.d.ts +11 -0
- package/dist/assert/greater-than-equal.d.ts.map +1 -0
- package/dist/assert/greater-than-equal.js +29 -0
- package/dist/assert/greater-than-equal.js.map +1 -0
- package/dist/assert/greater-than.cjs +33 -0
- package/dist/assert/greater-than.cjs.map +1 -0
- package/dist/assert/greater-than.d.cts +11 -0
- package/dist/assert/greater-than.d.cts.map +1 -0
- package/dist/assert/greater-than.d.ts +11 -0
- package/dist/assert/greater-than.d.ts.map +1 -0
- package/dist/assert/greater-than.js +30 -0
- package/dist/assert/greater-than.js.map +1 -0
- package/dist/assert/has-keys.cjs +58 -0
- package/dist/assert/has-keys.cjs.map +1 -0
- package/dist/assert/has-keys.d.cts +16 -0
- package/dist/assert/has-keys.d.cts.map +1 -0
- package/dist/assert/has-keys.d.ts +16 -0
- package/dist/assert/has-keys.d.ts.map +1 -0
- package/dist/assert/has-keys.js +54 -0
- package/dist/assert/has-keys.js.map +1 -0
- package/dist/assert/has-members.cjs +67 -0
- package/dist/assert/has-members.cjs.map +1 -0
- package/dist/assert/has-members.d.cts +48 -0
- package/dist/assert/has-members.d.cts.map +1 -0
- package/dist/assert/has-members.d.ts +48 -0
- package/dist/assert/has-members.d.ts.map +1 -0
- package/dist/assert/has-members.js +64 -0
- package/dist/assert/has-members.js.map +1 -0
- package/dist/assert/has-property.cjs +61 -0
- package/dist/assert/has-property.cjs.map +1 -0
- package/dist/assert/has-property.d.cts +22 -0
- package/dist/assert/has-property.d.cts.map +1 -0
- package/dist/assert/has-property.d.ts +22 -0
- package/dist/assert/has-property.d.ts.map +1 -0
- package/dist/assert/has-property.js +58 -0
- package/dist/assert/has-property.js.map +1 -0
- package/dist/assert/has-size.cjs +122 -0
- package/dist/assert/has-size.cjs.map +1 -0
- package/dist/assert/has-size.d.cts +42 -0
- package/dist/assert/has-size.d.cts.map +1 -0
- package/dist/assert/has-size.d.ts +42 -0
- package/dist/assert/has-size.d.ts.map +1 -0
- package/dist/assert/has-size.js +118 -0
- package/dist/assert/has-size.js.map +1 -0
- package/dist/assert/in-ballpark.cjs +44 -0
- package/dist/assert/in-ballpark.cjs.map +1 -0
- package/dist/assert/in-ballpark.d.cts +16 -0
- package/dist/assert/in-ballpark.d.cts.map +1 -0
- package/dist/assert/in-ballpark.d.ts +16 -0
- package/dist/assert/in-ballpark.d.ts.map +1 -0
- package/dist/assert/in-ballpark.js +41 -0
- package/dist/assert/in-ballpark.js.map +1 -0
- package/dist/assert/includes.cjs +30 -0
- package/dist/assert/includes.cjs.map +1 -0
- package/dist/assert/includes.d.cts +24 -0
- package/dist/assert/includes.d.cts.map +1 -0
- package/dist/assert/includes.d.ts +24 -0
- package/dist/assert/includes.d.ts.map +1 -0
- package/dist/assert/includes.js +27 -0
- package/dist/assert/includes.js.map +1 -0
- package/dist/assert/instance-of.cjs +36 -0
- package/dist/assert/instance-of.cjs.map +1 -0
- package/dist/assert/instance-of.d.cts +16 -0
- package/dist/assert/instance-of.d.cts.map +1 -0
- package/dist/assert/instance-of.d.ts +16 -0
- package/dist/assert/instance-of.d.ts.map +1 -0
- package/dist/assert/instance-of.js +32 -0
- package/dist/assert/instance-of.js.map +1 -0
- package/dist/assert/is-after.cjs +29 -0
- package/dist/assert/is-after.cjs.map +1 -0
- package/dist/assert/is-after.d.cts +11 -0
- package/dist/assert/is-after.d.cts.map +1 -0
- package/dist/assert/is-after.d.ts +11 -0
- package/dist/assert/is-after.d.ts.map +1 -0
- package/dist/assert/is-after.js +26 -0
- package/dist/assert/is-after.js.map +1 -0
- package/dist/assert/is-before.cjs +29 -0
- package/dist/assert/is-before.cjs.map +1 -0
- package/dist/assert/is-before.d.cts +11 -0
- package/dist/assert/is-before.d.cts.map +1 -0
- package/dist/assert/is-before.d.ts +11 -0
- package/dist/assert/is-before.d.ts.map +1 -0
- package/dist/assert/is-before.js +26 -0
- package/dist/assert/is-before.js.map +1 -0
- package/dist/assert/is-between.cjs +47 -0
- package/dist/assert/is-between.cjs.map +1 -0
- package/dist/assert/is-between.d.cts +15 -0
- package/dist/assert/is-between.d.cts.map +1 -0
- package/dist/assert/is-between.d.ts +15 -0
- package/dist/assert/is-between.d.ts.map +1 -0
- package/dist/assert/is-between.js +44 -0
- package/dist/assert/is-between.js.map +1 -0
- package/dist/assert/is-empty.cjs +98 -0
- package/dist/assert/is-empty.cjs.map +1 -0
- package/dist/assert/is-empty.d.cts +31 -0
- package/dist/assert/is-empty.d.cts.map +1 -0
- package/dist/assert/is-empty.d.ts +31 -0
- package/dist/assert/is-empty.d.ts.map +1 -0
- package/dist/assert/is-empty.js +94 -0
- package/dist/assert/is-empty.js.map +1 -0
- package/dist/assert/is-type.cjs +34 -0
- package/dist/assert/is-type.cjs.map +1 -0
- package/dist/assert/is-type.d.cts +97 -0
- package/dist/assert/is-type.d.cts.map +1 -0
- package/dist/assert/is-type.d.ts +97 -0
- package/dist/assert/is-type.d.ts.map +1 -0
- package/dist/assert/is-type.js +31 -0
- package/dist/assert/is-type.js.map +1 -0
- package/dist/assert/less-than-equal.cjs +36 -0
- package/dist/assert/less-than-equal.cjs.map +1 -0
- package/dist/assert/less-than-equal.d.cts +11 -0
- package/dist/assert/less-than-equal.d.cts.map +1 -0
- package/dist/assert/less-than-equal.d.ts +11 -0
- package/dist/assert/less-than-equal.d.ts.map +1 -0
- package/dist/assert/less-than-equal.js +33 -0
- package/dist/assert/less-than-equal.js.map +1 -0
- package/dist/assert/less-than.cjs +34 -0
- package/dist/assert/less-than.cjs.map +1 -0
- package/dist/assert/less-than.d.cts +11 -0
- package/dist/assert/less-than.d.cts.map +1 -0
- package/dist/assert/less-than.d.ts +11 -0
- package/dist/assert/less-than.d.ts.map +1 -0
- package/dist/assert/less-than.js +31 -0
- package/dist/assert/less-than.js.map +1 -0
- package/dist/assert/match.cjs +31 -0
- package/dist/assert/match.cjs.map +1 -0
- package/dist/assert/match.d.cts +15 -0
- package/dist/assert/match.d.cts.map +1 -0
- package/dist/assert/match.d.ts +15 -0
- package/dist/assert/match.d.ts.map +1 -0
- package/dist/assert/match.js +28 -0
- package/dist/assert/match.js.map +1 -0
- package/dist/assert/rejects.cjs +49 -0
- package/dist/assert/rejects.cjs.map +1 -0
- package/dist/assert/rejects.d.cts +36 -0
- package/dist/assert/rejects.d.cts.map +1 -0
- package/dist/assert/rejects.d.ts +36 -0
- package/dist/assert/rejects.d.ts.map +1 -0
- package/dist/assert/rejects.js +46 -0
- package/dist/assert/rejects.js.map +1 -0
- package/dist/assert/round-to.cjs +54 -0
- package/dist/assert/round-to.cjs.map +1 -0
- package/dist/assert/round-to.d.cts +15 -0
- package/dist/assert/round-to.d.cts.map +1 -0
- package/dist/assert/round-to.d.ts +15 -0
- package/dist/assert/round-to.d.ts.map +1 -0
- package/dist/assert/round-to.js +51 -0
- package/dist/assert/round-to.js.map +1 -0
- package/dist/assert/starts-with.cjs +30 -0
- package/dist/assert/starts-with.cjs.map +1 -0
- package/dist/assert/starts-with.d.cts +14 -0
- package/dist/assert/starts-with.d.cts.map +1 -0
- package/dist/assert/starts-with.d.ts +14 -0
- package/dist/assert/starts-with.d.ts.map +1 -0
- package/dist/assert/starts-with.js +27 -0
- package/dist/assert/starts-with.js.map +1 -0
- package/dist/assert/throws.cjs +41 -0
- package/dist/assert/throws.cjs.map +1 -0
- package/dist/{throws-CYLYG7gu.d.cts → assert/throws.d.cts} +4 -11
- package/dist/assert/throws.d.cts.map +1 -0
- package/dist/{throws-BlzO4xvg.d.ts → assert/throws.d.ts} +3 -12
- package/dist/assert/throws.d.ts.map +1 -0
- package/dist/assert/throws.js +38 -0
- package/dist/assert/throws.js.map +1 -0
- package/dist/assert.cjs +143 -52
- package/dist/assert.cjs.map +1 -0
- package/dist/assert.d.cts +34 -3
- package/dist/assert.d.cts.map +1 -0
- package/dist/assert.d.ts +34 -3
- package/dist/assert.d.ts.map +1 -0
- package/dist/assert.js +87 -2
- package/dist/assert.js.map +1 -0
- package/dist/expect/after.cjs +15 -0
- package/dist/expect/after.cjs.map +1 -0
- package/dist/expect/after.js +16 -0
- package/dist/expect/after.js.map +1 -0
- package/dist/expect/ballpark.cjs +15 -0
- package/dist/expect/ballpark.cjs.map +1 -0
- package/dist/expect/ballpark.js +16 -0
- package/dist/expect/ballpark.js.map +1 -0
- package/dist/expect/before.cjs +15 -0
- package/dist/expect/before.cjs.map +1 -0
- package/dist/expect/before.js +16 -0
- package/dist/expect/before.js.map +1 -0
- package/dist/expect/between.cjs +15 -0
- package/dist/expect/between.cjs.map +1 -0
- package/dist/expect/between.js +16 -0
- package/dist/expect/between.js.map +1 -0
- package/dist/expect/empty.cjs +15 -0
- package/dist/expect/empty.cjs.map +1 -0
- package/dist/expect/empty.js +16 -0
- package/dist/expect/empty.js.map +1 -0
- package/dist/expect/end-with.cjs +15 -0
- package/dist/expect/end-with.cjs.map +1 -0
- package/dist/expect/end-with.js +16 -0
- package/dist/expect/end-with.js.map +1 -0
- package/dist/expect/eql.cjs +21 -0
- package/dist/expect/eql.cjs.map +1 -0
- package/dist/expect/eql.js +22 -0
- package/dist/expect/eql.js.map +1 -0
- package/dist/expect/equal-shorthand.cjs +34 -0
- package/dist/expect/equal-shorthand.cjs.map +1 -0
- package/dist/expect/equal-shorthand.js +33 -0
- package/dist/expect/equal-shorthand.js.map +1 -0
- package/dist/expect/equal.cjs +27 -0
- package/dist/expect/equal.cjs.map +1 -0
- package/dist/expect/equal.js +28 -0
- package/dist/expect/equal.js.map +1 -0
- package/dist/expect/excluding.cjs +19 -0
- package/dist/expect/excluding.cjs.map +1 -0
- package/dist/expect/excluding.js +18 -0
- package/dist/expect/excluding.js.map +1 -0
- package/dist/expect/greater-than-equal.cjs +25 -0
- package/dist/expect/greater-than-equal.cjs.map +1 -0
- package/dist/expect/greater-than-equal.js +26 -0
- package/dist/expect/greater-than-equal.js.map +1 -0
- package/dist/expect/greater-than.cjs +25 -0
- package/dist/expect/greater-than.cjs.map +1 -0
- package/dist/expect/greater-than.js +26 -0
- package/dist/expect/greater-than.js.map +1 -0
- package/dist/expect/has-property.cjs +20 -0
- package/dist/expect/has-property.cjs.map +1 -0
- package/dist/expect/has-property.js +21 -0
- package/dist/expect/has-property.js.map +1 -0
- package/dist/expect/include.cjs +21 -0
- package/dist/expect/include.cjs.map +1 -0
- package/dist/expect/include.js +22 -0
- package/dist/expect/include.js.map +1 -0
- package/dist/expect/instance-of-shorthand.cjs +24 -0
- package/dist/expect/instance-of-shorthand.cjs.map +1 -0
- package/dist/expect/instance-of-shorthand.js +25 -0
- package/dist/expect/instance-of-shorthand.js.map +1 -0
- package/dist/expect/instance-of.cjs +15 -0
- package/dist/expect/instance-of.cjs.map +1 -0
- package/dist/expect/instance-of.js +16 -0
- package/dist/expect/instance-of.js.map +1 -0
- package/dist/expect/keys.cjs +15 -0
- package/dist/expect/keys.cjs.map +1 -0
- package/dist/expect/keys.js +16 -0
- package/dist/expect/keys.js.map +1 -0
- package/dist/expect/length.cjs +21 -0
- package/dist/expect/length.cjs.map +1 -0
- package/dist/expect/length.js +22 -0
- package/dist/expect/length.js.map +1 -0
- package/dist/expect/less-than-equal.cjs +25 -0
- package/dist/expect/less-than-equal.cjs.map +1 -0
- package/dist/expect/less-than-equal.js +26 -0
- package/dist/expect/less-than-equal.js.map +1 -0
- package/dist/expect/less-than.cjs +25 -0
- package/dist/expect/less-than.cjs.map +1 -0
- package/dist/expect/less-than.js +26 -0
- package/dist/expect/less-than.js.map +1 -0
- package/dist/expect/match.cjs +15 -0
- package/dist/expect/match.cjs.map +1 -0
- package/dist/expect/match.js +16 -0
- package/dist/expect/match.js.map +1 -0
- package/dist/expect/members.cjs +41 -0
- package/dist/expect/members.cjs.map +1 -0
- package/dist/expect/members.js +42 -0
- package/dist/expect/members.js.map +1 -0
- package/dist/expect/reject.cjs +14 -0
- package/dist/expect/reject.cjs.map +1 -0
- package/dist/expect/reject.js +15 -0
- package/dist/expect/reject.js.map +1 -0
- package/dist/expect/round-to.cjs +15 -0
- package/dist/expect/round-to.cjs.map +1 -0
- package/dist/expect/round-to.js +16 -0
- package/dist/expect/round-to.js.map +1 -0
- package/dist/expect/start-with.cjs +15 -0
- package/dist/expect/start-with.cjs.map +1 -0
- package/dist/expect/start-with.js +16 -0
- package/dist/expect/start-with.js.map +1 -0
- package/dist/expect/throw.cjs +14 -0
- package/dist/expect/throw.cjs.map +1 -0
- package/dist/expect/throw.js +15 -0
- package/dist/expect/throw.js.map +1 -0
- package/dist/expect/type-shorthand.cjs +29 -0
- package/dist/expect/type-shorthand.cjs.map +1 -0
- package/dist/expect/type-shorthand.js +30 -0
- package/dist/expect/type-shorthand.js.map +1 -0
- package/dist/expect/type.cjs +15 -0
- package/dist/expect/type.cjs.map +1 -0
- package/dist/expect/type.js +16 -0
- package/dist/expect/type.js.map +1 -0
- package/dist/expect.cjs +144 -0
- package/dist/expect.cjs.map +1 -0
- package/dist/expect.d.cts +10 -0
- package/dist/expect.d.cts.map +1 -0
- package/dist/expect.d.ts +10 -0
- package/dist/expect.d.ts.map +1 -0
- package/dist/expect.js +141 -0
- package/dist/expect.js.map +1 -0
- package/dist/expect.types.d.cts +67 -3
- package/dist/expect.types.d.cts.map +1 -0
- package/dist/expect.types.d.ts +67 -3
- package/dist/expect.types.d.ts.map +1 -0
- package/dist/index.cjs +13 -582
- package/dist/index.d.cts +8 -15
- package/dist/index.d.ts +8 -15
- package/dist/index.js +8 -575
- package/dist/mixins.cjs +11 -0
- package/dist/mixins.cjs.map +1 -0
- package/dist/mixins.d.cts +28 -0
- package/dist/mixins.d.cts.map +1 -0
- package/dist/mixins.d.ts +28 -0
- package/dist/mixins.d.ts.map +1 -0
- package/dist/mixins.js +9 -0
- package/dist/mixins.js.map +1 -0
- package/dist/utils/chain.cjs +20 -0
- package/dist/utils/chain.cjs.map +1 -0
- package/dist/utils/chain.js +18 -0
- package/dist/utils/chain.js.map +1 -0
- package/dist/utils/fail.cjs +16 -0
- package/dist/utils/fail.cjs.map +1 -0
- package/dist/utils/fail.d.cts +9 -0
- package/dist/utils/fail.d.cts.map +1 -0
- package/dist/utils/fail.d.ts +9 -0
- package/dist/utils/fail.d.ts.map +1 -0
- package/dist/utils/fail.js +14 -0
- package/dist/utils/fail.js.map +1 -0
- package/dist/utils/get-size.cjs +17 -0
- package/dist/utils/get-size.cjs.map +1 -0
- package/dist/utils/get-size.js +15 -0
- package/dist/utils/get-size.js.map +1 -0
- package/dist/utils/get-type.cjs +12 -0
- package/dist/utils/get-type.cjs.map +1 -0
- package/dist/utils/get-type.d.cts +5 -0
- package/dist/utils/get-type.d.cts.map +1 -0
- package/dist/utils/get-type.d.ts +5 -0
- package/dist/utils/get-type.d.ts.map +1 -0
- package/dist/utils/get-type.js +11 -0
- package/dist/utils/get-type.js.map +1 -0
- package/dist/utils/match.cjs +118 -0
- package/dist/utils/match.cjs.map +1 -0
- package/dist/utils/match.d.cts +7 -0
- package/dist/utils/match.d.cts.map +1 -0
- package/dist/utils/match.d.ts +7 -0
- package/dist/utils/match.d.ts.map +1 -0
- package/dist/utils/match.js +114 -0
- package/dist/utils/match.js.map +1 -0
- package/dist/utils/process-error.cjs +86 -0
- package/dist/utils/process-error.cjs.map +1 -0
- package/dist/utils/process-error.d.cts +8 -0
- package/dist/utils/process-error.d.cts.map +1 -0
- package/dist/utils/process-error.d.ts +10 -0
- package/dist/utils/process-error.d.ts.map +1 -0
- package/dist/utils/process-error.js +85 -0
- package/dist/utils/process-error.js.map +1 -0
- package/dist/utils/validate-numeric-and-dates.cjs +20 -0
- package/dist/utils/validate-numeric-and-dates.cjs.map +1 -0
- package/dist/utils/validate-numeric-and-dates.js +18 -0
- package/dist/utils/validate-numeric-and-dates.js.map +1 -0
- package/dist/utils/xor.cjs +9 -0
- package/dist/utils/xor.cjs.map +1 -0
- package/dist/utils/xor.js +8 -0
- package/dist/utils/xor.js.map +1 -0
- package/package.json +1 -1
- package/dist/assert-ChQPKP5C.d.cts +0 -480
- package/dist/assert-ChQPKP5C.d.cts.map +0 -1
- package/dist/assert-CsN7srt-.d.ts +0 -478
- package/dist/assert-CsN7srt-.d.ts.map +0 -1
- package/dist/assert-DZjgWjOw.cjs +0 -1626
- package/dist/assert-DZjgWjOw.cjs.map +0 -1
- package/dist/assert-kFXp7i_B.js +0 -1260
- package/dist/assert-kFXp7i_B.js.map +0 -1
- package/dist/expect.types-CHYPdbCW.d.cts +0 -454
- package/dist/expect.types-CHYPdbCW.d.cts.map +0 -1
- package/dist/expect.types-nBq4Rg8e.d.ts +0 -454
- package/dist/expect.types-nBq4Rg8e.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/throws-BlzO4xvg.d.ts.map +0 -1
- package/dist/throws-CYLYG7gu.d.cts.map +0 -1
- /package/dist/{chunk-CTAAG5j7.js → _virtual/rolldown_runtime.js} +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let hein_assertion_utils = require("hein-assertion-utils");
|
|
3
|
+
hein_assertion_utils = require_rolldown_runtime.__toESM(hein_assertion_utils);
|
|
4
|
+
|
|
5
|
+
//#region src/assert/has-property.ts
|
|
6
|
+
const [hasProperty, notHasProperty] = (0, hein_assertion_utils.createAssertion)({
|
|
7
|
+
messages: {
|
|
8
|
+
noProperty: "Expected {{= it.actual }} to have property {{= it.expected }}",
|
|
9
|
+
wrongValue: "Expected {{= it.obj }} to have property {{= it.expected }} with value {{= it.value }}",
|
|
10
|
+
not: "Expected {{= it.actual }} to not have property {{= it.expected }}",
|
|
11
|
+
notWrongValue: "Expected {{= it.obj }} to not have property {{= it.expected }} with value {{= it.value }}"
|
|
12
|
+
},
|
|
13
|
+
test: (report) => (...args) => {
|
|
14
|
+
const [actual, expected, value] = args;
|
|
15
|
+
const actualStringified = (0, hein_assertion_utils.stringify)(actual);
|
|
16
|
+
if (expected in actual) {
|
|
17
|
+
if (args.length === 3) {
|
|
18
|
+
if (actual[expected] === value) return report({
|
|
19
|
+
status: "ok",
|
|
20
|
+
messageId: "notWrongValue",
|
|
21
|
+
expected,
|
|
22
|
+
actual: actualStringified,
|
|
23
|
+
data: {
|
|
24
|
+
value,
|
|
25
|
+
expected,
|
|
26
|
+
obj: actual
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return report({
|
|
30
|
+
status: "notok",
|
|
31
|
+
messageId: "wrongValue",
|
|
32
|
+
expected,
|
|
33
|
+
actual: actualStringified,
|
|
34
|
+
data: {
|
|
35
|
+
value,
|
|
36
|
+
obj: actualStringified
|
|
37
|
+
},
|
|
38
|
+
noStringify: true
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return report({
|
|
42
|
+
status: "ok",
|
|
43
|
+
noStringify: true,
|
|
44
|
+
expected,
|
|
45
|
+
actual: actualStringified
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return report({
|
|
49
|
+
status: "notok",
|
|
50
|
+
messageId: "noProperty",
|
|
51
|
+
expected,
|
|
52
|
+
actual: actualStringified,
|
|
53
|
+
noStringify: true
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
exports.hasProperty = hasProperty;
|
|
60
|
+
exports.notHasProperty = notHasProperty;
|
|
61
|
+
//# sourceMappingURL=has-property.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-property.cjs","names":[],"sources":["../../src/assert/has-property.ts"],"sourcesContent":["import { createAssertion, stringify } from 'hein-assertion-utils';\n\ninterface HasProperty {\n /**\n * check if object has a property\n * @param object\n * @param property a property in the object.\n * @example hasProperty({a: 1}, 'a');\n */\n <T, K extends keyof T>(object: T, property: K): void;\n /**\n * check if object has a property with a specific value\n * @param object\n * @param property a property in the object.\n * @param value\n * @example hasProperty({a: 1}, 'a', 1);\n */\n <T, K extends keyof T>(object: T, property: K, value: T[K]): void;\n}\n\nexport const [hasProperty, notHasProperty] = createAssertion({\n messages: {\n noProperty: 'Expected {{= it.actual }} to have property {{= it.expected }}',\n wrongValue: 'Expected {{= it.obj }} to have property {{= it.expected }} with value {{= it.value }}',\n not: 'Expected {{= it.actual }} to not have property {{= it.expected }}',\n notWrongValue: 'Expected {{= it.obj }} to not have property {{= it.expected }} with value {{= it.value }}'\n },\n test:\n (report): HasProperty =>\n <T extends object, K extends keyof T>(...args: [actual: T, expected: K, value?: T[K]]) => {\n const [actual, expected, value] = args;\n const actualStringified = stringify(actual);\n if (expected in actual) {\n if (args.length === 3) {\n if (actual[expected] === value) {\n return report({\n status: 'ok',\n messageId: 'notWrongValue',\n expected,\n actual: actualStringified as any,\n data: { value, expected, obj: actual }\n });\n }\n return report({\n status: 'notok',\n messageId: 'wrongValue',\n expected,\n actual: actualStringified as any,\n data: { value, obj: actualStringified as any },\n noStringify: true\n });\n }\n return report({ status: 'ok', noStringify: true, expected, actual: actualStringified as any });\n }\n return report({\n status: 'notok',\n messageId: 'noProperty',\n expected,\n actual: actualStringified as any,\n noStringify: true\n });\n }\n});\n"],"mappings":";;;;;AAoBA,MAAa,CAAC,aAAa,4DAAkC;CACzD,UAAU;EACN,YAAY;EACZ,YAAY;EACZ,KAAK;EACL,eAAe;EAClB;CACD,OACK,YACqC,GAAG,SAAiD;EACtF,MAAM,CAAC,QAAQ,UAAU,SAAS;EAClC,MAAM,wDAA8B,OAAO;AAC3C,MAAI,YAAY,QAAQ;AACpB,OAAI,KAAK,WAAW,GAAG;AACnB,QAAI,OAAO,cAAc,MACrB,QAAO,OAAO;KACV,QAAQ;KACR,WAAW;KACX;KACA,QAAQ;KACR,MAAM;MAAE;MAAO;MAAU,KAAK;MAAQ;KACzC,CAAC;AAEN,WAAO,OAAO;KACV,QAAQ;KACR,WAAW;KACX;KACA,QAAQ;KACR,MAAM;MAAE;MAAO,KAAK;MAA0B;KAC9C,aAAa;KAChB,CAAC;;AAEN,UAAO,OAAO;IAAE,QAAQ;IAAM,aAAa;IAAM;IAAU,QAAQ;IAA0B,CAAC;;AAElG,SAAO,OAAO;GACV,QAAQ;GACR,WAAW;GACX;GACA,QAAQ;GACR,aAAa;GAChB,CAAC;;CAEb,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/assert/has-property.d.ts
|
|
2
|
+
interface HasProperty {
|
|
3
|
+
/**
|
|
4
|
+
* check if object has a property
|
|
5
|
+
* @param object
|
|
6
|
+
* @param property a property in the object.
|
|
7
|
+
* @example hasProperty({a: 1}, 'a');
|
|
8
|
+
*/
|
|
9
|
+
<T, K extends keyof T>(object: T, property: K): void;
|
|
10
|
+
/**
|
|
11
|
+
* check if object has a property with a specific value
|
|
12
|
+
* @param object
|
|
13
|
+
* @param property a property in the object.
|
|
14
|
+
* @param value
|
|
15
|
+
* @example hasProperty({a: 1}, 'a', 1);
|
|
16
|
+
*/
|
|
17
|
+
<T, K extends keyof T>(object: T, property: K, value: T[K]): void;
|
|
18
|
+
}
|
|
19
|
+
declare const hasProperty: HasProperty, notHasProperty: HasProperty;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { hasProperty, notHasProperty };
|
|
22
|
+
//# sourceMappingURL=has-property.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-property.d.cts","names":[],"sources":["../../src/assert/has-property.ts"],"sourcesContent":[],"mappings":";UAEU,WAAA;EAAA;;;;;;MAeyB,UAAA,MARX,CAQW,CAAA,CAAA,MAAA,EARA,CAQA,EAAA,QAAA,EARa,CAQb,CAAA,EAAA,IAAA;;;;;AAGnC;;;MAAyC,UAAA,MAHjB,CAGiB,CAAA,CAAA,MAAA,EAHN,CAGM,EAAA,QAAA,EAHO,CAGP,EAAA,KAAA,EAHiB,CAGjB,CAHmB,CAGnB,CAAA,CAAA,EAAA,IAAA;;AAAd,cAAb,WAAa,EAAF,WAAE,EAAA,cAAA,EAAc,WAAd"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/assert/has-property.d.ts
|
|
2
|
+
interface HasProperty {
|
|
3
|
+
/**
|
|
4
|
+
* check if object has a property
|
|
5
|
+
* @param object
|
|
6
|
+
* @param property a property in the object.
|
|
7
|
+
* @example hasProperty({a: 1}, 'a');
|
|
8
|
+
*/
|
|
9
|
+
<T, K extends keyof T>(object: T, property: K): void;
|
|
10
|
+
/**
|
|
11
|
+
* check if object has a property with a specific value
|
|
12
|
+
* @param object
|
|
13
|
+
* @param property a property in the object.
|
|
14
|
+
* @param value
|
|
15
|
+
* @example hasProperty({a: 1}, 'a', 1);
|
|
16
|
+
*/
|
|
17
|
+
<T, K extends keyof T>(object: T, property: K, value: T[K]): void;
|
|
18
|
+
}
|
|
19
|
+
declare const hasProperty: HasProperty, notHasProperty: HasProperty;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { hasProperty, notHasProperty };
|
|
22
|
+
//# sourceMappingURL=has-property.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-property.d.ts","names":[],"sources":["../../src/assert/has-property.ts"],"sourcesContent":[],"mappings":";UAEU,WAAA;EAAA;;;;;;MAeyB,UAAA,MARX,CAQW,CAAA,CAAA,MAAA,EARA,CAQA,EAAA,QAAA,EARa,CAQb,CAAA,EAAA,IAAA;;;;;AAGnC;;;MAAyC,UAAA,MAHjB,CAGiB,CAAA,CAAA,MAAA,EAHN,CAGM,EAAA,QAAA,EAHO,CAGP,EAAA,KAAA,EAHiB,CAGjB,CAHmB,CAGnB,CAAA,CAAA,EAAA,IAAA;;AAAd,cAAb,WAAa,EAAF,WAAE,EAAA,cAAA,EAAc,WAAd"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createAssertion, stringify } from "hein-assertion-utils";
|
|
2
|
+
|
|
3
|
+
//#region src/assert/has-property.ts
|
|
4
|
+
const [hasProperty, notHasProperty] = createAssertion({
|
|
5
|
+
messages: {
|
|
6
|
+
noProperty: "Expected {{= it.actual }} to have property {{= it.expected }}",
|
|
7
|
+
wrongValue: "Expected {{= it.obj }} to have property {{= it.expected }} with value {{= it.value }}",
|
|
8
|
+
not: "Expected {{= it.actual }} to not have property {{= it.expected }}",
|
|
9
|
+
notWrongValue: "Expected {{= it.obj }} to not have property {{= it.expected }} with value {{= it.value }}"
|
|
10
|
+
},
|
|
11
|
+
test: (report) => (...args) => {
|
|
12
|
+
const [actual, expected, value] = args;
|
|
13
|
+
const actualStringified = stringify(actual);
|
|
14
|
+
if (expected in actual) {
|
|
15
|
+
if (args.length === 3) {
|
|
16
|
+
if (actual[expected] === value) return report({
|
|
17
|
+
status: "ok",
|
|
18
|
+
messageId: "notWrongValue",
|
|
19
|
+
expected,
|
|
20
|
+
actual: actualStringified,
|
|
21
|
+
data: {
|
|
22
|
+
value,
|
|
23
|
+
expected,
|
|
24
|
+
obj: actual
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return report({
|
|
28
|
+
status: "notok",
|
|
29
|
+
messageId: "wrongValue",
|
|
30
|
+
expected,
|
|
31
|
+
actual: actualStringified,
|
|
32
|
+
data: {
|
|
33
|
+
value,
|
|
34
|
+
obj: actualStringified
|
|
35
|
+
},
|
|
36
|
+
noStringify: true
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return report({
|
|
40
|
+
status: "ok",
|
|
41
|
+
noStringify: true,
|
|
42
|
+
expected,
|
|
43
|
+
actual: actualStringified
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return report({
|
|
47
|
+
status: "notok",
|
|
48
|
+
messageId: "noProperty",
|
|
49
|
+
expected,
|
|
50
|
+
actual: actualStringified,
|
|
51
|
+
noStringify: true
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { hasProperty, notHasProperty };
|
|
58
|
+
//# sourceMappingURL=has-property.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-property.js","names":[],"sources":["../../src/assert/has-property.ts"],"sourcesContent":["import { createAssertion, stringify } from 'hein-assertion-utils';\n\ninterface HasProperty {\n /**\n * check if object has a property\n * @param object\n * @param property a property in the object.\n * @example hasProperty({a: 1}, 'a');\n */\n <T, K extends keyof T>(object: T, property: K): void;\n /**\n * check if object has a property with a specific value\n * @param object\n * @param property a property in the object.\n * @param value\n * @example hasProperty({a: 1}, 'a', 1);\n */\n <T, K extends keyof T>(object: T, property: K, value: T[K]): void;\n}\n\nexport const [hasProperty, notHasProperty] = createAssertion({\n messages: {\n noProperty: 'Expected {{= it.actual }} to have property {{= it.expected }}',\n wrongValue: 'Expected {{= it.obj }} to have property {{= it.expected }} with value {{= it.value }}',\n not: 'Expected {{= it.actual }} to not have property {{= it.expected }}',\n notWrongValue: 'Expected {{= it.obj }} to not have property {{= it.expected }} with value {{= it.value }}'\n },\n test:\n (report): HasProperty =>\n <T extends object, K extends keyof T>(...args: [actual: T, expected: K, value?: T[K]]) => {\n const [actual, expected, value] = args;\n const actualStringified = stringify(actual);\n if (expected in actual) {\n if (args.length === 3) {\n if (actual[expected] === value) {\n return report({\n status: 'ok',\n messageId: 'notWrongValue',\n expected,\n actual: actualStringified as any,\n data: { value, expected, obj: actual }\n });\n }\n return report({\n status: 'notok',\n messageId: 'wrongValue',\n expected,\n actual: actualStringified as any,\n data: { value, obj: actualStringified as any },\n noStringify: true\n });\n }\n return report({ status: 'ok', noStringify: true, expected, actual: actualStringified as any });\n }\n return report({\n status: 'notok',\n messageId: 'noProperty',\n expected,\n actual: actualStringified as any,\n noStringify: true\n });\n }\n});\n"],"mappings":";;;AAoBA,MAAa,CAAC,aAAa,kBAAkB,gBAAgB;CACzD,UAAU;EACN,YAAY;EACZ,YAAY;EACZ,KAAK;EACL,eAAe;EAClB;CACD,OACK,YACqC,GAAG,SAAiD;EACtF,MAAM,CAAC,QAAQ,UAAU,SAAS;EAClC,MAAM,oBAAoB,UAAU,OAAO;AAC3C,MAAI,YAAY,QAAQ;AACpB,OAAI,KAAK,WAAW,GAAG;AACnB,QAAI,OAAO,cAAc,MACrB,QAAO,OAAO;KACV,QAAQ;KACR,WAAW;KACX;KACA,QAAQ;KACR,MAAM;MAAE;MAAO;MAAU,KAAK;MAAQ;KACzC,CAAC;AAEN,WAAO,OAAO;KACV,QAAQ;KACR,WAAW;KACX;KACA,QAAQ;KACR,MAAM;MAAE;MAAO,KAAK;MAA0B;KAC9C,aAAa;KAChB,CAAC;;AAEN,UAAO,OAAO;IAAE,QAAQ;IAAM,aAAa;IAAM;IAAU,QAAQ;IAA0B,CAAC;;AAElG,SAAO,OAAO;GACV,QAAQ;GACR,WAAW;GACX;GACA,QAAQ;GACR,aAAa;GAChB,CAAC;;CAEb,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let hein_assertion_utils = require("hein-assertion-utils");
|
|
3
|
+
hein_assertion_utils = require_rolldown_runtime.__toESM(hein_assertion_utils);
|
|
4
|
+
let lodash_isPlainObject_js = require("lodash/isPlainObject.js");
|
|
5
|
+
lodash_isPlainObject_js = require_rolldown_runtime.__toESM(lodash_isPlainObject_js);
|
|
6
|
+
|
|
7
|
+
//#region src/assert/has-size.ts
|
|
8
|
+
const [hasSize, notHasSize] = (0, hein_assertion_utils.createAssertion)({
|
|
9
|
+
messages: {
|
|
10
|
+
array: "Expected array to have length of {{= it.expected }}",
|
|
11
|
+
object: "Expected object to have size of {{= it.expected }}",
|
|
12
|
+
map: "Expected Map to have size of {{= it.expected }}",
|
|
13
|
+
set: "Expected Set to have size of {{= it.expected }}",
|
|
14
|
+
string: "Expected string to have length of {{= it.expected }}",
|
|
15
|
+
not: "Expected array to not have length of {{= it.expected }}",
|
|
16
|
+
notObject: "Expected object to not have size of {{= it.expected }}",
|
|
17
|
+
notMap: "Expected Map to not have size of {{= it.expected }}",
|
|
18
|
+
notSet: "Expected Set to not have size of {{= it.expected }}",
|
|
19
|
+
notString: "Expected string to not have length of {{= it.expected }}",
|
|
20
|
+
invalidValue: "Expected {{= it.actual }} to be an array, object, Map, Set or string"
|
|
21
|
+
},
|
|
22
|
+
test: (report) => (actual, expected, message) => {
|
|
23
|
+
if (Array.isArray(actual)) {
|
|
24
|
+
if (actual.length === expected) return report({
|
|
25
|
+
message,
|
|
26
|
+
status: "ok",
|
|
27
|
+
expected,
|
|
28
|
+
actual: actual.length
|
|
29
|
+
});
|
|
30
|
+
return report({
|
|
31
|
+
message,
|
|
32
|
+
status: "notok",
|
|
33
|
+
messageId: "array",
|
|
34
|
+
expected,
|
|
35
|
+
actual: actual.length
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if ((0, lodash_isPlainObject_js.default)(actual)) {
|
|
39
|
+
if (Object.keys(actual).length === expected) return report({
|
|
40
|
+
message,
|
|
41
|
+
status: "ok",
|
|
42
|
+
messageId: "notObject",
|
|
43
|
+
expected,
|
|
44
|
+
actual: Object.keys(actual).length
|
|
45
|
+
});
|
|
46
|
+
return report({
|
|
47
|
+
message,
|
|
48
|
+
status: "notok",
|
|
49
|
+
messageId: "object",
|
|
50
|
+
expected,
|
|
51
|
+
actual: Object.keys(actual).length
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (actual instanceof Map) {
|
|
55
|
+
if (actual.size === expected) return report({
|
|
56
|
+
message,
|
|
57
|
+
status: "ok",
|
|
58
|
+
messageId: "notMap",
|
|
59
|
+
expected,
|
|
60
|
+
actual: actual.size
|
|
61
|
+
});
|
|
62
|
+
return report({
|
|
63
|
+
message,
|
|
64
|
+
status: "notok",
|
|
65
|
+
messageId: "map",
|
|
66
|
+
expected,
|
|
67
|
+
actual: actual.size
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (actual instanceof Set) {
|
|
71
|
+
if (actual.size === expected) return report({
|
|
72
|
+
message,
|
|
73
|
+
status: "ok",
|
|
74
|
+
messageId: "notSet",
|
|
75
|
+
expected,
|
|
76
|
+
actual: actual.size
|
|
77
|
+
});
|
|
78
|
+
return report({
|
|
79
|
+
message,
|
|
80
|
+
status: "notok",
|
|
81
|
+
messageId: "set",
|
|
82
|
+
expected,
|
|
83
|
+
actual: actual.size
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (typeof actual === "string") {
|
|
87
|
+
if (actual.length === expected) return report({
|
|
88
|
+
message,
|
|
89
|
+
status: "ok",
|
|
90
|
+
messageId: "notString",
|
|
91
|
+
expected,
|
|
92
|
+
actual: actual.length
|
|
93
|
+
});
|
|
94
|
+
return report({
|
|
95
|
+
message,
|
|
96
|
+
status: "notok",
|
|
97
|
+
messageId: "string",
|
|
98
|
+
expected,
|
|
99
|
+
actual: actual.length
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
report({
|
|
103
|
+
message,
|
|
104
|
+
status: "notok",
|
|
105
|
+
messageId: "invalidValue",
|
|
106
|
+
actual: typeof actual,
|
|
107
|
+
noStringify: true
|
|
108
|
+
});
|
|
109
|
+
report({
|
|
110
|
+
message,
|
|
111
|
+
status: "ok",
|
|
112
|
+
messageId: "invalidValue",
|
|
113
|
+
actual: typeof actual,
|
|
114
|
+
noStringify: true
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
120
|
+
exports.hasSize = hasSize;
|
|
121
|
+
exports.notHasSize = notHasSize;
|
|
122
|
+
//# sourceMappingURL=has-size.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-size.cjs","names":[],"sources":["../../src/assert/has-size.ts"],"sourcesContent":["import isPlainObject from 'lodash/isPlainObject.js';\nimport { createAssertion } from 'hein-assertion-utils';\n\ninterface HasSize {\n /**\n * check if array has a specific length\n * @param array\n * @param length\n * @example hasSize([1, 2, 3], 3);\n */\n (array: any[], length: number, message?: string): void;\n /**\n * check if object has a specific amount of keys\n * @param object\n * @param length\n * @example hasSize({a: 1, b: 2}, 2);\n */\n (object: Record<string, unknown>, length: number, message?: string): void;\n /**\n * check if Map has a specific amount of keys\n * @param map\n * @param length\n * @example hasSize(new Map([['a', 1], ['b', 2]]), 2);\n */\n (map: Map<unknown, unknown>, length: number, message?: string): void;\n /**\n * check if Set has a specific amount of members\n * @param set\n * @param length\n * @example hasSize(new Set([1, 2, 3]), 3);\n */\n (set: Set<unknown>, length: number, message?: string): void;\n /**\n * check if string has a specific length\n * @param string\n * @param length\n * @example hasSize('abc', 3);\n */\n (string: string, length: number, message?: string): void;\n}\n\nexport const [hasSize, notHasSize] = createAssertion({\n messages: {\n array: 'Expected array to have length of {{= it.expected }}',\n object: 'Expected object to have size of {{= it.expected }}',\n map: 'Expected Map to have size of {{= it.expected }}',\n set: 'Expected Set to have size of {{= it.expected }}',\n string: 'Expected string to have length of {{= it.expected }}',\n not: 'Expected array to not have length of {{= it.expected }}',\n notObject: 'Expected object to not have size of {{= it.expected }}',\n notMap: 'Expected Map to not have size of {{= it.expected }}',\n notSet: 'Expected Set to not have size of {{= it.expected }}',\n notString: 'Expected string to not have length of {{= it.expected }}',\n invalidValue: 'Expected {{= it.actual }} to be an array, object, Map, Set or string'\n },\n test:\n (report): HasSize =>\n <T>(actual: T, expected: number, message?: string) => {\n if (Array.isArray(actual)) {\n if (actual.length === expected) {\n return report({ message, status: 'ok', expected, actual: actual.length });\n }\n return report({ message, status: 'notok', messageId: 'array', expected, actual: actual.length });\n }\n if (isPlainObject(actual)) {\n if (Object.keys(actual).length === expected) {\n return report({\n message,\n status: 'ok',\n messageId: 'notObject',\n expected,\n actual: Object.keys(actual).length\n });\n }\n return report({\n message,\n status: 'notok',\n messageId: 'object',\n expected,\n actual: Object.keys(actual).length\n });\n }\n if (actual instanceof Map) {\n if (actual.size === expected) {\n return report({ message, status: 'ok', messageId: 'notMap', expected, actual: actual.size });\n }\n return report({ message, status: 'notok', messageId: 'map', expected, actual: actual.size });\n }\n if (actual instanceof Set) {\n if (actual.size === expected) {\n return report({ message, status: 'ok', messageId: 'notSet', expected, actual: actual.size });\n }\n return report({ message, status: 'notok', messageId: 'set', expected, actual: actual.size });\n }\n if (typeof actual === 'string') {\n if (actual.length === expected) {\n return report({ message, status: 'ok', messageId: 'notString', expected, actual: actual.length });\n }\n return report({ message, status: 'notok', messageId: 'string', expected, actual: actual.length });\n }\n report({ message, status: 'notok', messageId: 'invalidValue', actual: typeof actual, noStringify: true });\n report({ message, status: 'ok', messageId: 'invalidValue', actual: typeof actual, noStringify: true });\n }\n});\n"],"mappings":";;;;;;;AAyCA,MAAa,CAAC,SAAS,wDAA8B;CACjD,UAAU;EACN,OAAO;EACP,QAAQ;EACR,KAAK;EACL,KAAK;EACL,QAAQ;EACR,KAAK;EACL,WAAW;EACX,QAAQ;EACR,QAAQ;EACR,WAAW;EACX,cAAc;EACjB;CACD,OACK,YACG,QAAW,UAAkB,YAAqB;AAClD,MAAI,MAAM,QAAQ,OAAO,EAAE;AACvB,OAAI,OAAO,WAAW,SAClB,QAAO,OAAO;IAAE;IAAS,QAAQ;IAAM;IAAU,QAAQ,OAAO;IAAQ,CAAC;AAE7E,UAAO,OAAO;IAAE;IAAS,QAAQ;IAAS,WAAW;IAAS;IAAU,QAAQ,OAAO;IAAQ,CAAC;;AAEpG,2CAAkB,OAAO,EAAE;AACvB,OAAI,OAAO,KAAK,OAAO,CAAC,WAAW,SAC/B,QAAO,OAAO;IACV;IACA,QAAQ;IACR,WAAW;IACX;IACA,QAAQ,OAAO,KAAK,OAAO,CAAC;IAC/B,CAAC;AAEN,UAAO,OAAO;IACV;IACA,QAAQ;IACR,WAAW;IACX;IACA,QAAQ,OAAO,KAAK,OAAO,CAAC;IAC/B,CAAC;;AAEN,MAAI,kBAAkB,KAAK;AACvB,OAAI,OAAO,SAAS,SAChB,QAAO,OAAO;IAAE;IAAS,QAAQ;IAAM,WAAW;IAAU;IAAU,QAAQ,OAAO;IAAM,CAAC;AAEhG,UAAO,OAAO;IAAE;IAAS,QAAQ;IAAS,WAAW;IAAO;IAAU,QAAQ,OAAO;IAAM,CAAC;;AAEhG,MAAI,kBAAkB,KAAK;AACvB,OAAI,OAAO,SAAS,SAChB,QAAO,OAAO;IAAE;IAAS,QAAQ;IAAM,WAAW;IAAU;IAAU,QAAQ,OAAO;IAAM,CAAC;AAEhG,UAAO,OAAO;IAAE;IAAS,QAAQ;IAAS,WAAW;IAAO;IAAU,QAAQ,OAAO;IAAM,CAAC;;AAEhG,MAAI,OAAO,WAAW,UAAU;AAC5B,OAAI,OAAO,WAAW,SAClB,QAAO,OAAO;IAAE;IAAS,QAAQ;IAAM,WAAW;IAAa;IAAU,QAAQ,OAAO;IAAQ,CAAC;AAErG,UAAO,OAAO;IAAE;IAAS,QAAQ;IAAS,WAAW;IAAU;IAAU,QAAQ,OAAO;IAAQ,CAAC;;AAErG,SAAO;GAAE;GAAS,QAAQ;GAAS,WAAW;GAAgB,QAAQ,OAAO;GAAQ,aAAa;GAAM,CAAC;AACzG,SAAO;GAAE;GAAS,QAAQ;GAAM,WAAW;GAAgB,QAAQ,OAAO;GAAQ,aAAa;GAAM,CAAC;;CAEjH,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/assert/has-size.d.ts
|
|
2
|
+
interface HasSize {
|
|
3
|
+
/**
|
|
4
|
+
* check if array has a specific length
|
|
5
|
+
* @param array
|
|
6
|
+
* @param length
|
|
7
|
+
* @example hasSize([1, 2, 3], 3);
|
|
8
|
+
*/
|
|
9
|
+
(array: any[], length: number, message?: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* check if object has a specific amount of keys
|
|
12
|
+
* @param object
|
|
13
|
+
* @param length
|
|
14
|
+
* @example hasSize({a: 1, b: 2}, 2);
|
|
15
|
+
*/
|
|
16
|
+
(object: Record<string, unknown>, length: number, message?: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* check if Map has a specific amount of keys
|
|
19
|
+
* @param map
|
|
20
|
+
* @param length
|
|
21
|
+
* @example hasSize(new Map([['a', 1], ['b', 2]]), 2);
|
|
22
|
+
*/
|
|
23
|
+
(map: Map<unknown, unknown>, length: number, message?: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* check if Set has a specific amount of members
|
|
26
|
+
* @param set
|
|
27
|
+
* @param length
|
|
28
|
+
* @example hasSize(new Set([1, 2, 3]), 3);
|
|
29
|
+
*/
|
|
30
|
+
(set: Set<unknown>, length: number, message?: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* check if string has a specific length
|
|
33
|
+
* @param string
|
|
34
|
+
* @param length
|
|
35
|
+
* @example hasSize('abc', 3);
|
|
36
|
+
*/
|
|
37
|
+
(string: string, length: number, message?: string): void;
|
|
38
|
+
}
|
|
39
|
+
declare const hasSize: HasSize, notHasSize: HasSize;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { hasSize, notHasSize };
|
|
42
|
+
//# sourceMappingURL=has-size.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-size.d.cts","names":[],"sources":["../../src/assert/has-size.ts"],"sourcesContent":[],"mappings":";UAGU,OAAA;EAAA;;;;;;EAsCI,CAAA,KAAA,EAAA,GAAO,EAAA,EAAA,MAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAA;;;;;;WAxBR;;;;;;;QAOH;;;;;;;QAOA;;;;;;;;;cAUI,SAAO,qBAAY"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/assert/has-size.d.ts
|
|
2
|
+
interface HasSize {
|
|
3
|
+
/**
|
|
4
|
+
* check if array has a specific length
|
|
5
|
+
* @param array
|
|
6
|
+
* @param length
|
|
7
|
+
* @example hasSize([1, 2, 3], 3);
|
|
8
|
+
*/
|
|
9
|
+
(array: any[], length: number, message?: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* check if object has a specific amount of keys
|
|
12
|
+
* @param object
|
|
13
|
+
* @param length
|
|
14
|
+
* @example hasSize({a: 1, b: 2}, 2);
|
|
15
|
+
*/
|
|
16
|
+
(object: Record<string, unknown>, length: number, message?: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* check if Map has a specific amount of keys
|
|
19
|
+
* @param map
|
|
20
|
+
* @param length
|
|
21
|
+
* @example hasSize(new Map([['a', 1], ['b', 2]]), 2);
|
|
22
|
+
*/
|
|
23
|
+
(map: Map<unknown, unknown>, length: number, message?: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* check if Set has a specific amount of members
|
|
26
|
+
* @param set
|
|
27
|
+
* @param length
|
|
28
|
+
* @example hasSize(new Set([1, 2, 3]), 3);
|
|
29
|
+
*/
|
|
30
|
+
(set: Set<unknown>, length: number, message?: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* check if string has a specific length
|
|
33
|
+
* @param string
|
|
34
|
+
* @param length
|
|
35
|
+
* @example hasSize('abc', 3);
|
|
36
|
+
*/
|
|
37
|
+
(string: string, length: number, message?: string): void;
|
|
38
|
+
}
|
|
39
|
+
declare const hasSize: HasSize, notHasSize: HasSize;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { hasSize, notHasSize };
|
|
42
|
+
//# sourceMappingURL=has-size.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-size.d.ts","names":[],"sources":["../../src/assert/has-size.ts"],"sourcesContent":[],"mappings":";UAGU,OAAA;EAAA;;;;;;EAsCI,CAAA,KAAA,EAAA,GAAO,EAAA,EAAA,MAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAA;;;;;;WAxBR;;;;;;;QAOH;;;;;;;QAOA;;;;;;;;;cAUI,SAAO,qBAAY"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { createAssertion } from "hein-assertion-utils";
|
|
2
|
+
import isPlainObject from "lodash/isPlainObject.js";
|
|
3
|
+
|
|
4
|
+
//#region src/assert/has-size.ts
|
|
5
|
+
const [hasSize, notHasSize] = createAssertion({
|
|
6
|
+
messages: {
|
|
7
|
+
array: "Expected array to have length of {{= it.expected }}",
|
|
8
|
+
object: "Expected object to have size of {{= it.expected }}",
|
|
9
|
+
map: "Expected Map to have size of {{= it.expected }}",
|
|
10
|
+
set: "Expected Set to have size of {{= it.expected }}",
|
|
11
|
+
string: "Expected string to have length of {{= it.expected }}",
|
|
12
|
+
not: "Expected array to not have length of {{= it.expected }}",
|
|
13
|
+
notObject: "Expected object to not have size of {{= it.expected }}",
|
|
14
|
+
notMap: "Expected Map to not have size of {{= it.expected }}",
|
|
15
|
+
notSet: "Expected Set to not have size of {{= it.expected }}",
|
|
16
|
+
notString: "Expected string to not have length of {{= it.expected }}",
|
|
17
|
+
invalidValue: "Expected {{= it.actual }} to be an array, object, Map, Set or string"
|
|
18
|
+
},
|
|
19
|
+
test: (report) => (actual, expected, message) => {
|
|
20
|
+
if (Array.isArray(actual)) {
|
|
21
|
+
if (actual.length === expected) return report({
|
|
22
|
+
message,
|
|
23
|
+
status: "ok",
|
|
24
|
+
expected,
|
|
25
|
+
actual: actual.length
|
|
26
|
+
});
|
|
27
|
+
return report({
|
|
28
|
+
message,
|
|
29
|
+
status: "notok",
|
|
30
|
+
messageId: "array",
|
|
31
|
+
expected,
|
|
32
|
+
actual: actual.length
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (isPlainObject(actual)) {
|
|
36
|
+
if (Object.keys(actual).length === expected) return report({
|
|
37
|
+
message,
|
|
38
|
+
status: "ok",
|
|
39
|
+
messageId: "notObject",
|
|
40
|
+
expected,
|
|
41
|
+
actual: Object.keys(actual).length
|
|
42
|
+
});
|
|
43
|
+
return report({
|
|
44
|
+
message,
|
|
45
|
+
status: "notok",
|
|
46
|
+
messageId: "object",
|
|
47
|
+
expected,
|
|
48
|
+
actual: Object.keys(actual).length
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (actual instanceof Map) {
|
|
52
|
+
if (actual.size === expected) return report({
|
|
53
|
+
message,
|
|
54
|
+
status: "ok",
|
|
55
|
+
messageId: "notMap",
|
|
56
|
+
expected,
|
|
57
|
+
actual: actual.size
|
|
58
|
+
});
|
|
59
|
+
return report({
|
|
60
|
+
message,
|
|
61
|
+
status: "notok",
|
|
62
|
+
messageId: "map",
|
|
63
|
+
expected,
|
|
64
|
+
actual: actual.size
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (actual instanceof Set) {
|
|
68
|
+
if (actual.size === expected) return report({
|
|
69
|
+
message,
|
|
70
|
+
status: "ok",
|
|
71
|
+
messageId: "notSet",
|
|
72
|
+
expected,
|
|
73
|
+
actual: actual.size
|
|
74
|
+
});
|
|
75
|
+
return report({
|
|
76
|
+
message,
|
|
77
|
+
status: "notok",
|
|
78
|
+
messageId: "set",
|
|
79
|
+
expected,
|
|
80
|
+
actual: actual.size
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (typeof actual === "string") {
|
|
84
|
+
if (actual.length === expected) return report({
|
|
85
|
+
message,
|
|
86
|
+
status: "ok",
|
|
87
|
+
messageId: "notString",
|
|
88
|
+
expected,
|
|
89
|
+
actual: actual.length
|
|
90
|
+
});
|
|
91
|
+
return report({
|
|
92
|
+
message,
|
|
93
|
+
status: "notok",
|
|
94
|
+
messageId: "string",
|
|
95
|
+
expected,
|
|
96
|
+
actual: actual.length
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
report({
|
|
100
|
+
message,
|
|
101
|
+
status: "notok",
|
|
102
|
+
messageId: "invalidValue",
|
|
103
|
+
actual: typeof actual,
|
|
104
|
+
noStringify: true
|
|
105
|
+
});
|
|
106
|
+
report({
|
|
107
|
+
message,
|
|
108
|
+
status: "ok",
|
|
109
|
+
messageId: "invalidValue",
|
|
110
|
+
actual: typeof actual,
|
|
111
|
+
noStringify: true
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
//#endregion
|
|
117
|
+
export { hasSize, notHasSize };
|
|
118
|
+
//# sourceMappingURL=has-size.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-size.js","names":[],"sources":["../../src/assert/has-size.ts"],"sourcesContent":["import isPlainObject from 'lodash/isPlainObject.js';\nimport { createAssertion } from 'hein-assertion-utils';\n\ninterface HasSize {\n /**\n * check if array has a specific length\n * @param array\n * @param length\n * @example hasSize([1, 2, 3], 3);\n */\n (array: any[], length: number, message?: string): void;\n /**\n * check if object has a specific amount of keys\n * @param object\n * @param length\n * @example hasSize({a: 1, b: 2}, 2);\n */\n (object: Record<string, unknown>, length: number, message?: string): void;\n /**\n * check if Map has a specific amount of keys\n * @param map\n * @param length\n * @example hasSize(new Map([['a', 1], ['b', 2]]), 2);\n */\n (map: Map<unknown, unknown>, length: number, message?: string): void;\n /**\n * check if Set has a specific amount of members\n * @param set\n * @param length\n * @example hasSize(new Set([1, 2, 3]), 3);\n */\n (set: Set<unknown>, length: number, message?: string): void;\n /**\n * check if string has a specific length\n * @param string\n * @param length\n * @example hasSize('abc', 3);\n */\n (string: string, length: number, message?: string): void;\n}\n\nexport const [hasSize, notHasSize] = createAssertion({\n messages: {\n array: 'Expected array to have length of {{= it.expected }}',\n object: 'Expected object to have size of {{= it.expected }}',\n map: 'Expected Map to have size of {{= it.expected }}',\n set: 'Expected Set to have size of {{= it.expected }}',\n string: 'Expected string to have length of {{= it.expected }}',\n not: 'Expected array to not have length of {{= it.expected }}',\n notObject: 'Expected object to not have size of {{= it.expected }}',\n notMap: 'Expected Map to not have size of {{= it.expected }}',\n notSet: 'Expected Set to not have size of {{= it.expected }}',\n notString: 'Expected string to not have length of {{= it.expected }}',\n invalidValue: 'Expected {{= it.actual }} to be an array, object, Map, Set or string'\n },\n test:\n (report): HasSize =>\n <T>(actual: T, expected: number, message?: string) => {\n if (Array.isArray(actual)) {\n if (actual.length === expected) {\n return report({ message, status: 'ok', expected, actual: actual.length });\n }\n return report({ message, status: 'notok', messageId: 'array', expected, actual: actual.length });\n }\n if (isPlainObject(actual)) {\n if (Object.keys(actual).length === expected) {\n return report({\n message,\n status: 'ok',\n messageId: 'notObject',\n expected,\n actual: Object.keys(actual).length\n });\n }\n return report({\n message,\n status: 'notok',\n messageId: 'object',\n expected,\n actual: Object.keys(actual).length\n });\n }\n if (actual instanceof Map) {\n if (actual.size === expected) {\n return report({ message, status: 'ok', messageId: 'notMap', expected, actual: actual.size });\n }\n return report({ message, status: 'notok', messageId: 'map', expected, actual: actual.size });\n }\n if (actual instanceof Set) {\n if (actual.size === expected) {\n return report({ message, status: 'ok', messageId: 'notSet', expected, actual: actual.size });\n }\n return report({ message, status: 'notok', messageId: 'set', expected, actual: actual.size });\n }\n if (typeof actual === 'string') {\n if (actual.length === expected) {\n return report({ message, status: 'ok', messageId: 'notString', expected, actual: actual.length });\n }\n return report({ message, status: 'notok', messageId: 'string', expected, actual: actual.length });\n }\n report({ message, status: 'notok', messageId: 'invalidValue', actual: typeof actual, noStringify: true });\n report({ message, status: 'ok', messageId: 'invalidValue', actual: typeof actual, noStringify: true });\n }\n});\n"],"mappings":";;;;AAyCA,MAAa,CAAC,SAAS,cAAc,gBAAgB;CACjD,UAAU;EACN,OAAO;EACP,QAAQ;EACR,KAAK;EACL,KAAK;EACL,QAAQ;EACR,KAAK;EACL,WAAW;EACX,QAAQ;EACR,QAAQ;EACR,WAAW;EACX,cAAc;EACjB;CACD,OACK,YACG,QAAW,UAAkB,YAAqB;AAClD,MAAI,MAAM,QAAQ,OAAO,EAAE;AACvB,OAAI,OAAO,WAAW,SAClB,QAAO,OAAO;IAAE;IAAS,QAAQ;IAAM;IAAU,QAAQ,OAAO;IAAQ,CAAC;AAE7E,UAAO,OAAO;IAAE;IAAS,QAAQ;IAAS,WAAW;IAAS;IAAU,QAAQ,OAAO;IAAQ,CAAC;;AAEpG,MAAI,cAAc,OAAO,EAAE;AACvB,OAAI,OAAO,KAAK,OAAO,CAAC,WAAW,SAC/B,QAAO,OAAO;IACV;IACA,QAAQ;IACR,WAAW;IACX;IACA,QAAQ,OAAO,KAAK,OAAO,CAAC;IAC/B,CAAC;AAEN,UAAO,OAAO;IACV;IACA,QAAQ;IACR,WAAW;IACX;IACA,QAAQ,OAAO,KAAK,OAAO,CAAC;IAC/B,CAAC;;AAEN,MAAI,kBAAkB,KAAK;AACvB,OAAI,OAAO,SAAS,SAChB,QAAO,OAAO;IAAE;IAAS,QAAQ;IAAM,WAAW;IAAU;IAAU,QAAQ,OAAO;IAAM,CAAC;AAEhG,UAAO,OAAO;IAAE;IAAS,QAAQ;IAAS,WAAW;IAAO;IAAU,QAAQ,OAAO;IAAM,CAAC;;AAEhG,MAAI,kBAAkB,KAAK;AACvB,OAAI,OAAO,SAAS,SAChB,QAAO,OAAO;IAAE;IAAS,QAAQ;IAAM,WAAW;IAAU;IAAU,QAAQ,OAAO;IAAM,CAAC;AAEhG,UAAO,OAAO;IAAE;IAAS,QAAQ;IAAS,WAAW;IAAO;IAAU,QAAQ,OAAO;IAAM,CAAC;;AAEhG,MAAI,OAAO,WAAW,UAAU;AAC5B,OAAI,OAAO,WAAW,SAClB,QAAO,OAAO;IAAE;IAAS,QAAQ;IAAM,WAAW;IAAa;IAAU,QAAQ,OAAO;IAAQ,CAAC;AAErG,UAAO,OAAO;IAAE;IAAS,QAAQ;IAAS,WAAW;IAAU;IAAU,QAAQ,OAAO;IAAQ,CAAC;;AAErG,SAAO;GAAE;GAAS,QAAQ;GAAS,WAAW;GAAgB,QAAQ,OAAO;GAAQ,aAAa;GAAM,CAAC;AACzG,SAAO;GAAE;GAAS,QAAQ;GAAM,WAAW;GAAgB,QAAQ,OAAO;GAAQ,aAAa;GAAM,CAAC;;CAEjH,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let hein_assertion_utils = require("hein-assertion-utils");
|
|
3
|
+
hein_assertion_utils = require_rolldown_runtime.__toESM(hein_assertion_utils);
|
|
4
|
+
|
|
5
|
+
//#region src/assert/in-ballpark.ts
|
|
6
|
+
const [inBallpark, notInBallpark] = (0, hein_assertion_utils.createAssertion)({
|
|
7
|
+
messages: {
|
|
8
|
+
miss: "Expected {{= it.actual }} to be in ballpark of {{= it.expected }}",
|
|
9
|
+
not: "Expected {{= it.actual }} to not be in ballpark of {{= it.expected }}",
|
|
10
|
+
invalidMultiplier: "Expected multiplier to be between 0 and 1"
|
|
11
|
+
},
|
|
12
|
+
test: (report) => (actual, expected, allowedDifference = .1) => {
|
|
13
|
+
const absActual = Math.abs(actual);
|
|
14
|
+
const absExpected = Math.abs(expected);
|
|
15
|
+
if (allowedDifference <= 0 || allowedDifference >= 1) {
|
|
16
|
+
report({
|
|
17
|
+
status: "ok",
|
|
18
|
+
messageId: "invalidMultiplier",
|
|
19
|
+
actual: allowedDifference
|
|
20
|
+
});
|
|
21
|
+
return report({
|
|
22
|
+
status: "notok",
|
|
23
|
+
messageId: "invalidMultiplier",
|
|
24
|
+
actual: allowedDifference
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (absActual <= absExpected * (1 + allowedDifference) && absActual >= absExpected * (1 - allowedDifference)) return report({
|
|
28
|
+
status: "ok",
|
|
29
|
+
expected,
|
|
30
|
+
actual
|
|
31
|
+
});
|
|
32
|
+
return report({
|
|
33
|
+
status: "notok",
|
|
34
|
+
messageId: "miss",
|
|
35
|
+
expected,
|
|
36
|
+
actual
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
exports.inBallpark = inBallpark;
|
|
43
|
+
exports.notInBallpark = notInBallpark;
|
|
44
|
+
//# sourceMappingURL=in-ballpark.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-ballpark.cjs","names":[],"sources":["../../src/assert/in-ballpark.ts"],"sourcesContent":["import { createAssertion } from 'hein-assertion-utils';\n\ninterface InBallpark {\n /**\n * check if a number is in ballpark of another number. See also roundTo\n * @param actual\n * @param expected\n * @param [allowedDifferenceMultiplier=0.1] - a number between 0 and 1 (exclusive). 0.1 (default) means 10% difference is allowed.\n * @example inBallpark(1, 1.1);\n * @example inBallpark(1, 1.1, 0.1);\n */\n (actual: number, expected: number, allowedDifferenceMultiplier?: number): void;\n}\n\nexport const [inBallpark, notInBallpark] = createAssertion({\n messages: {\n miss: 'Expected {{= it.actual }} to be in ballpark of {{= it.expected }}',\n not: 'Expected {{= it.actual }} to not be in ballpark of {{= it.expected }}',\n invalidMultiplier: 'Expected multiplier to be between 0 and 1'\n },\n test:\n (report): InBallpark =>\n (actual: number, expected: number, allowedDifference = 0.1) => {\n const absActual = Math.abs(actual);\n const absExpected = Math.abs(expected);\n if (allowedDifference <= 0 || allowedDifference >= 1) {\n report({ status: 'ok', messageId: 'invalidMultiplier', actual: allowedDifference });\n return report({ status: 'notok', messageId: 'invalidMultiplier', actual: allowedDifference });\n }\n if (\n absActual <= absExpected * (1 + allowedDifference) &&\n absActual >= absExpected * (1 - allowedDifference)\n ) {\n return report({ status: 'ok', expected, actual });\n }\n return report({ status: 'notok', messageId: 'miss', expected, actual });\n }\n});\n"],"mappings":";;;;;AAcA,MAAa,CAAC,YAAY,2DAAiC;CACvD,UAAU;EACN,MAAM;EACN,KAAK;EACL,mBAAmB;EACtB;CACD,OACK,YACA,QAAgB,UAAkB,oBAAoB,OAAQ;EAC3D,MAAM,YAAY,KAAK,IAAI,OAAO;EAClC,MAAM,cAAc,KAAK,IAAI,SAAS;AACtC,MAAI,qBAAqB,KAAK,qBAAqB,GAAG;AAClD,UAAO;IAAE,QAAQ;IAAM,WAAW;IAAqB,QAAQ;IAAmB,CAAC;AACnF,UAAO,OAAO;IAAE,QAAQ;IAAS,WAAW;IAAqB,QAAQ;IAAmB,CAAC;;AAEjG,MACI,aAAa,eAAe,IAAI,sBAChC,aAAa,eAAe,IAAI,mBAEhC,QAAO,OAAO;GAAE,QAAQ;GAAM;GAAU;GAAQ,CAAC;AAErD,SAAO,OAAO;GAAE,QAAQ;GAAS,WAAW;GAAQ;GAAU;GAAQ,CAAC;;CAElF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/assert/in-ballpark.d.ts
|
|
2
|
+
interface InBallpark {
|
|
3
|
+
/**
|
|
4
|
+
* check if a number is in ballpark of another number. See also roundTo
|
|
5
|
+
* @param actual
|
|
6
|
+
* @param expected
|
|
7
|
+
* @param [allowedDifferenceMultiplier=0.1] - a number between 0 and 1 (exclusive). 0.1 (default) means 10% difference is allowed.
|
|
8
|
+
* @example inBallpark(1, 1.1);
|
|
9
|
+
* @example inBallpark(1, 1.1, 0.1);
|
|
10
|
+
*/
|
|
11
|
+
(actual: number, expected: number, allowedDifferenceMultiplier?: number): void;
|
|
12
|
+
}
|
|
13
|
+
declare const inBallpark: InBallpark, notInBallpark: InBallpark;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { inBallpark, notInBallpark };
|
|
16
|
+
//# sourceMappingURL=in-ballpark.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-ballpark.d.cts","names":[],"sources":["../../src/assert/in-ballpark.ts"],"sourcesContent":[],"mappings":";UAEU,UAAA;EAAA;AAYV;;;;;;;;;cAAc,YAAU,2BAAe"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/assert/in-ballpark.d.ts
|
|
2
|
+
interface InBallpark {
|
|
3
|
+
/**
|
|
4
|
+
* check if a number is in ballpark of another number. See also roundTo
|
|
5
|
+
* @param actual
|
|
6
|
+
* @param expected
|
|
7
|
+
* @param [allowedDifferenceMultiplier=0.1] - a number between 0 and 1 (exclusive). 0.1 (default) means 10% difference is allowed.
|
|
8
|
+
* @example inBallpark(1, 1.1);
|
|
9
|
+
* @example inBallpark(1, 1.1, 0.1);
|
|
10
|
+
*/
|
|
11
|
+
(actual: number, expected: number, allowedDifferenceMultiplier?: number): void;
|
|
12
|
+
}
|
|
13
|
+
declare const inBallpark: InBallpark, notInBallpark: InBallpark;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { inBallpark, notInBallpark };
|
|
16
|
+
//# sourceMappingURL=in-ballpark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-ballpark.d.ts","names":[],"sources":["../../src/assert/in-ballpark.ts"],"sourcesContent":[],"mappings":";UAEU,UAAA;EAAA;AAYV;;;;;;;;;cAAc,YAAU,2BAAe"}
|