diff --git a/src/__tests__/options-get-iterator-method.spec-d.ts b/src/__tests__/options-get-iterator-method.spec-d.ts new file mode 100644 index 0000000..096d8f7 --- /dev/null +++ b/src/__tests__/options-get-iterator-method.spec-d.ts @@ -0,0 +1,17 @@ +/** + * @file Type Tests - GetIteratorMethodOptions + * @module aggregate-error-ponyfill/tests/unit-d/GetIteratorMethodOptions + */ + +import type getIteratorMethod from 'es-abstract/helpers/getIteratorMethod' +import type TestSubject from '../options-get-iterator-method' + +describe('unit-d:GetIteratorMethodOptions', () => { + it('should equal Parameters["0"]', () => { + // Arrange + type Expected = Parameters['0'] + + // Expect + expectTypeOf().toEqualTypeOf + }) +}) diff --git a/src/__tests__/options.spec-d.ts b/src/__tests__/options.spec-d.ts new file mode 100644 index 0000000..6aa9300 --- /dev/null +++ b/src/__tests__/options.spec-d.ts @@ -0,0 +1,19 @@ +/** + * @file Type Tests - Options + * @module aggregate-error-ponyfill/tests/unit-d/Options + */ + +import type { KeysRequired } from '@flex-development/tutils' +import type TestSubject from '../options' + +describe('unit-d:Options', () => { + it('should allow empty object', () => { + expectTypeOf>().toBeNever() + }) + + it('should match [cause?: Cause | undefined]', () => { + expectTypeOf() + .toHaveProperty('cause') + .toEqualTypeOf() + }) +}) diff --git a/src/__tests__/ponyfill.spec-d.ts b/src/__tests__/ponyfill.spec-d.ts new file mode 100644 index 0000000..73a3adc --- /dev/null +++ b/src/__tests__/ponyfill.spec-d.ts @@ -0,0 +1,24 @@ +/** + * @file Type Tests - AggregateError + * @module aggregate-error-ponyfill/tests/unit-d/AggregateError + */ + +import type TestSubject from '../ponyfill' + +describe('unit-d:AggregateError', () => { + it('should extend Error', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [cause?: Cause | undefined]', () => { + expectTypeOf>() + .toHaveProperty('cause') + .toEqualTypeOf() + }) + + it('should match [errors: T[]]', () => { + expectTypeOf>() + .toHaveProperty('errors') + .toEqualTypeOf<(Error | string)[]>() + }) +}) diff --git a/src/__tests__/ponyfill.spec.ts b/src/__tests__/ponyfill.spec.ts index 4d4bb89..086c9bf 100644 --- a/src/__tests__/ponyfill.spec.ts +++ b/src/__tests__/ponyfill.spec.ts @@ -1,11 +1,11 @@ /** - * @file Unit Tests - ponyfill - * @module aggregate-error-ponyfill/tests/unit/ponyfill + * @file Unit Tests - AggregateError + * @module aggregate-error-ponyfill/tests/unit/AggregateError */ import TestSubject from '../ponyfill' -describe('unit:ponyfill', () => { +describe('unit:AggregateError', () => { it('should create spec-compliant AggregateError', () => { // Arrange const cause = new Error('The server responded with a 500 status') diff --git a/src/options-get-iterator-method.ts b/src/options-get-iterator-method.ts index cb2fea8..b9e6416 100644 --- a/src/options-get-iterator-method.ts +++ b/src/options-get-iterator-method.ts @@ -1,6 +1,6 @@ /** * @file AggregateError - GetIteratorMethodOptions - * @module aggregate-error-ponyfill/ponyfill/GetIteratorMethodOptions + * @module aggregate-error-ponyfill/GetIteratorMethodOptions */ import type getIteratorMethod from 'es-abstract/helpers/getIteratorMethod' diff --git a/src/options.ts b/src/options.ts index b11915c..fe18ace 100644 --- a/src/options.ts +++ b/src/options.ts @@ -1,6 +1,6 @@ /** * @file AggregateError - Options - * @module aggregate-error-ponyfill/ponyfill/Options + * @module aggregate-error-ponyfill/Options */ /** @@ -19,7 +19,7 @@ interface Options { * * @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/cause */ - cause?: Cause + cause?: Cause | undefined } export type { Options as default } diff --git a/src/ponyfill.ts b/src/ponyfill.ts index 939347a..02a7c78 100644 --- a/src/ponyfill.ts +++ b/src/ponyfill.ts @@ -1,6 +1,6 @@ /** - * @file AggregateError - Ponyfill - * @module aggregate-error-ponyfill/ponyfill + * @file AggregateError + * @module aggregate-error-ponyfill/AggregateError */ import AdvanceStringIndex from 'es-abstract/2021/AdvanceStringIndex' @@ -26,21 +26,21 @@ import type GetIteratorMethodOptions from './options-get-iterator-method' * @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AggregateError * * @template T - Aggregated error type - * @template C - Error cause type + * @template Cause - Error cause type * * @class * @extends {Error} */ -class AggregateError extends Error { +class AggregateError extends Error { /** * Error cause. * * @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/cause * * @public - * @member {C | undefined} cause + * @member {Cause | undefined} cause */ - public cause?: C + public cause?: Cause | undefined /** * @public @@ -67,10 +67,10 @@ class AggregateError extends Error { * * @param {Iterable} errors - An iterable of errors * @param {string} [message] - Human-readable description of the error - * @param {Options} [options] - Error options - * @param {C} [options.cause] - The original cause of the error + * @param {Options} [options] - Error options + * @param {Cause} [options.cause] - The original cause of the error */ - constructor(errors: Iterable, message?: string, options?: Options) { + constructor(errors: Iterable, message?: string, options?: Options) { super(message) /**