@augment-vir/assert 30.0.4 → 30.1.0

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.
Files changed (56) hide show
  1. package/dist/assertions/boolean.d.ts +2 -2
  2. package/dist/assertions/boundary.d.ts +2 -2
  3. package/dist/assertions/enum.d.ts +2 -2
  4. package/dist/assertions/equality/entry-equality.d.ts +2 -2
  5. package/dist/assertions/equality/json-equality.d.ts +2 -2
  6. package/dist/assertions/equality/json-equality.js +1 -1
  7. package/dist/assertions/equality/simple-equality.d.ts +2 -2
  8. package/dist/assertions/equality/ts-type-equality.d.ts +4 -17
  9. package/dist/assertions/equality/ts-type-equality.js +1 -0
  10. package/dist/assertions/extendable-assertions.d.ts +43 -914
  11. package/dist/assertions/http.d.ts +1 -1
  12. package/dist/assertions/instance.d.ts +3 -3
  13. package/dist/assertions/keys.d.ts +3 -3
  14. package/dist/assertions/keys.js +1 -1
  15. package/dist/assertions/length.d.ts +2 -3
  16. package/dist/assertions/nullish.d.ts +2 -2
  17. package/dist/assertions/output.d.ts +2 -2
  18. package/dist/assertions/primitive.d.ts +3 -3
  19. package/dist/assertions/promise.d.ts +1 -1
  20. package/dist/assertions/runtime-type.d.ts +3 -3
  21. package/dist/assertions/throws.d.ts +2 -2
  22. package/dist/assertions/uuid.d.ts +2 -2
  23. package/dist/assertions/values.d.ts +2 -2
  24. package/dist/augments/guards/assert-wrap.d.ts +3 -254
  25. package/dist/augments/guards/assert.d.ts +4 -155
  26. package/dist/augments/guards/assert.js +6 -3
  27. package/dist/augments/guards/check-wrap.d.ts +4 -255
  28. package/dist/augments/guards/check-wrap.js +1 -1
  29. package/dist/augments/guards/check.d.ts +4 -255
  30. package/dist/augments/guards/wait-until.d.ts +3 -229
  31. package/dist/guard-types/assert-wrap-function.d.ts +2 -2
  32. package/dist/guard-types/check-function.d.ts +2 -2
  33. package/dist/guard-types/check-wrap-wrapper-function.d.ts +3 -3
  34. package/dist/guard-types/guard-override.d.ts +1 -1
  35. package/dist/guard-types/wait-until-function.d.ts +3 -4
  36. package/dist/index.d.ts +1 -1
  37. package/dist/test-timeout.mock.d.ts +2 -2
  38. package/package.json +2 -2
  39. package/dist/assertions/output.example.d.ts +0 -1
  40. package/dist/assertions/output.example.js +0 -13
  41. package/dist/assertions/runtime-type.example.d.ts +0 -1
  42. package/dist/assertions/runtime-type.example.js +0 -3
  43. package/dist/assertions/throws.example.d.ts +0 -1
  44. package/dist/assertions/throws.example.js +0 -11
  45. package/dist/augments/assertion.error.example.d.ts +0 -1
  46. package/dist/augments/assertion.error.example.js +0 -3
  47. package/dist/augments/guards/assert-wrap.example.d.ts +0 -1
  48. package/dist/augments/guards/assert-wrap.example.js +0 -9
  49. package/dist/augments/guards/assert.example.d.ts +0 -1
  50. package/dist/augments/guards/assert.example.js +0 -4
  51. package/dist/augments/guards/check-wrap.example.d.ts +0 -1
  52. package/dist/augments/guards/check-wrap.example.js +0 -9
  53. package/dist/augments/guards/check.example.d.ts +0 -1
  54. package/dist/augments/guards/check.example.js +0 -5
  55. package/dist/augments/guards/wait-until.example.d.ts +0 -1
  56. package/dist/augments/guards/wait-until.example.js +0 -13
@@ -1,6 +1,6 @@
1
1
  import type { AnyFunction, MaybePromise, NarrowToExpected, PartialWithUndefined, RemoveFirstTupleEntry, RemoveLastTupleEntry, RequiredAndNotNull } from '@augment-vir/core';
2
- import { ExtractKeysWithMatchingValues, Overwrite } from '@augment-vir/core';
3
- import { AnyDuration } from '@date-vir/duration';
2
+ import { type ExtractKeysWithMatchingValues, type Overwrite } from '@augment-vir/core';
3
+ import { type AnyDuration } from '@date-vir/duration';
4
4
  import type { AssertFunction } from './assert-function.js';
5
5
  import { autoGuardSymbol } from './guard-override.js';
6
6
  /**
@@ -37,7 +37,7 @@ export type WaitUntilFunction<Assert extends AssertFunction<any>> = Assert exten
37
37
  options?: WaitUntilOptions | undefined,
38
38
  failureMessage?: string | undefined
39
39
  ]) => Promise<NarrowToExpected<Input, Guard>> : never;
40
- type WaitUntilGroup<Asserts extends Readonly<Record<string, AssertFunction<any>>>, WaitUntilOverrides extends WaitUntilOverridesBase> = Omit<Overwrite<{
40
+ export type WaitUntilGroup<Asserts extends Readonly<Record<string, AssertFunction<any>>>, WaitUntilOverrides extends WaitUntilOverridesBase> = Omit<Overwrite<{
41
41
  [Name in keyof Asserts as Asserts[Name] extends AssertFunction<any> ? Name : never]: WaitUntilFunction<Asserts[Name]>;
42
42
  }, {
43
43
  [Name in keyof WaitUntilOverrides]: WaitUntilOverrides[Name] extends typeof autoGuardSymbol ? Name extends keyof Asserts ? Asserts[Name] extends AssertFunction<any> ? WaitUntilFunction<Asserts[Name]> : never : never : WaitUntilOverrides[Name];
@@ -65,4 +65,3 @@ export declare function parseWaitUntilArgs(rawArgs: unknown[]): {
65
65
  failureMessage: string | undefined;
66
66
  };
67
67
  export declare function parseWaitUntilOptions(rawOptions: WaitUntilOptions | undefined): RequiredAndNotNull<WaitUntilOptions>;
68
- export {};
package/dist/index.d.ts CHANGED
@@ -6,4 +6,4 @@ export * from './augments/guards/check-wrap.js';
6
6
  export * from './augments/guards/check.js';
7
7
  export * from './augments/guards/wait-until.js';
8
8
  export * from './augments/if-equals.js';
9
- export type { WaitUntilOptions } from './guard-types/wait-until-function.js';
9
+ export { type WaitUntilOptions } from './guard-types/wait-until-function.js';
@@ -1,3 +1,3 @@
1
- import { RequiredAndNotNull } from '@augment-vir/core';
2
- import type { WaitUntilOptions } from './guard-types/wait-until-function.js';
1
+ import { type RequiredAndNotNull } from '@augment-vir/core';
2
+ import { type WaitUntilOptions } from './guard-types/wait-until-function.js';
3
3
  export declare const waitUntilTestOptions: RequiredAndNotNull<WaitUntilOptions>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/assert",
3
- "version": "30.0.4",
3
+ "version": "30.1.0",
4
4
  "description": "A collection of assertions for test and production code alike.",
5
5
  "keywords": [
6
6
  "augment",
@@ -41,7 +41,7 @@
41
41
  "test:update": "npm test"
42
42
  },
43
43
  "dependencies": {
44
- "@augment-vir/core": "^30.0.4",
44
+ "@augment-vir/core": "^30.1.0",
45
45
  "@date-vir/duration": "^6.0.0",
46
46
  "deep-eql": "^5.0.2",
47
47
  "expect-type": "^0.20.0",
@@ -1 +0,0 @@
1
- export {};
@@ -1,13 +0,0 @@
1
- import { assert, AssertionError } from '@augment-vir/assert';
2
- function myFunctionToTest(name) {
3
- return `Hello there ${name}`;
4
- }
5
- const myCustomAsserter = (actual, expected, failureMessage) => {
6
- // Write your assertion in an `if`.
7
- if (!actual.startsWith('hello there') || actual.endsWith(expected)) {
8
- // Throw an `AssertionError` if the `if` fails.
9
- throw new AssertionError('', failureMessage);
10
- }
11
- };
12
- // Use your custom asserter as the first input to any `.output` guard.
13
- assert.output(myCustomAsserter, myFunctionToTest, ['John'], 'John', 'Name insertion failed');
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { getRuntimeType } from '@augment-vir/assert';
2
- getRuntimeType(['a']); // RuntimeType.Array
3
- getRuntimeType({ a: 'a' }); // RuntimeType.Object
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- import { assert } from '@augment-vir/assert';
2
- // define the options
3
- const matchOptions = {
4
- matchConstructor: Error,
5
- matchMessage: 'some error',
6
- };
7
- assert.throws(() => {
8
- throw new Error('some error');
9
- },
10
- // use the options
11
- matchOptions); // this assertion will pass
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { AssertionError } from '@augment-vir/assert';
2
- // the message from this error will be: `'User defined message: The assertion failed.'`
3
- throw new AssertionError('The assertion failed.', 'User defined message.');
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- import { assertWrap } from '@augment-vir/assert';
2
- // `result1` will be `['a']`
3
- const result1 = assertWrap.deepEquals(['a'], ['a']);
4
- const value = 'some value';
5
- // `result2` will be `'some value'` and it will have the type of `string`
6
- const result2 = assertWrap.isString(value);
7
- const value2 = 'some value';
8
- // this will throw an error
9
- const result3 = assertWrap.isNumber(value2);
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- import { assert } from '@augment-vir/assert';
2
- const value = 'some value';
3
- assert.isString(value);
4
- // `value` will now be typed as a `string`
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- import { checkWrap } from '@augment-vir/assert';
2
- // `result1` will be `['a']`
3
- const result1 = checkWrap.deepEquals(['a'], ['a']);
4
- const value = 'some value';
5
- // `result2` will be `'some value'` and it will have the type of `string`
6
- const result2 = checkWrap.isString(value);
7
- const value2 = 'some value';
8
- // `result` will be `undefined`
9
- const result3 = checkWrap.isNumber(value2);
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import { check } from '@augment-vir/assert';
2
- const value = 'some value';
3
- if (check.isString(value)) {
4
- // `value` will now be typed as a `string` in here
5
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,13 +0,0 @@
1
- import { waitUntil } from '@augment-vir/assert';
2
- // `result` will eventually be `'123'`
3
- const result = await waitUntil.isString(() => {
4
- if (Math.random() < 0.5) {
5
- return 123;
6
- }
7
- else {
8
- return '123';
9
- }
10
- }, {
11
- interval: { milliseconds: 100 },
12
- timeout: { seconds: 10 },
13
- });