-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lexus Drumgold <[email protected]>
- Loading branch information
1 parent
87a2292
commit 1d9dd7c
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @file Type Tests - GetFormatHook | ||
* @module esm-types/hooks/tests/unit-d/GetFormatHook | ||
*/ | ||
|
||
import type { ResolvedModuleUrl } from '#src/types' | ||
import type TestSubject from '../get-format' | ||
import type GetFormatHookContext from '../get-format-context' | ||
import type GetFormatHookResult from '../get-format-result' | ||
|
||
describe('unit-d:hooks/GetFormatHook', () => { | ||
it('should be callable with [ResolvedModuleUrl, GetFormatHookContext, GetFormatHook]', () => { | ||
// Arrange | ||
type Expected = [ | ||
url: ResolvedModuleUrl, | ||
context: GetFormatHookContext, | ||
defaultGetFormat: TestSubject | ||
] | ||
|
||
// Expect | ||
expectTypeOf<TestSubject>().parameters.toEqualTypeOf<Expected>() | ||
}) | ||
|
||
it('should return Promise<GetFormatHookResult>', () => { | ||
// Arrange | ||
type Expected = Promise<GetFormatHookResult> | ||
|
||
// Expect | ||
expectTypeOf<TestSubject>().returns.toEqualTypeOf<Expected>() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* @file Hooks - GetFormatHook | ||
* @module esm-types/hooks/GetFormatHook | ||
*/ | ||
|
||
import type { ResolvedModuleUrl } from '#src/types' | ||
import type GetFormatHookContext from './get-format-context' | ||
import type GetFormatHookResult from './get-format-result' | ||
|
||
/** | ||
* Determines how the given module `url` should be interpreted. | ||
* | ||
* The `format` returned also affects what the acceptable forms of source values | ||
* are for a module when parsing. | ||
* | ||
* @see {@linkcode GetFormatHookContext} | ||
* @see {@linkcode GetFormatHookResult} | ||
* @see {@linkcode ResolvedModuleUrl} | ||
* @see https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_getformat_url_context_defaultgetformat | ||
* | ||
* @async | ||
* | ||
* @param {ResolvedModuleUrl} url - Resolved module URL | ||
* @param {GetFormatHookContext} context - Hook context | ||
* @param {GetFormatHook} defaultGetFormat - Default Node.js hook | ||
* @return {Promise<GetFormatHookResult>} Hook result | ||
*/ | ||
type GetFormatHook = ( | ||
url: ResolvedModuleUrl, | ||
context: GetFormatHookContext, | ||
defaultGetFormat: GetFormatHook | ||
) => Promise<GetFormatHookResult> | ||
|
||
export type { GetFormatHook as default } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters