Skip to content

Commit

Permalink
feat: align hook and testFn invocation interfaces (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph authored Sep 1, 2023
1 parent 99d7efb commit 7c97f42
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AggregatedIdentifier } from '../ids';

import type { InvocationMetadata } from '../types';
import { BaseMetadata } from './BaseMetadata';
import type { DescribeBlockMetadata } from './DescribeBlockMetadata';
import type { HookDefinitionMetadata } from './HookDefinitionMetadata';
Expand All @@ -9,8 +10,11 @@ import type { TestInvocationMetadata } from './TestInvocationMetadata';
type HookInvocationParentMetadata = DescribeBlockMetadata | TestInvocationMetadata;

export class HookInvocationMetadata<
ParentMetadata extends HookInvocationParentMetadata = HookInvocationParentMetadata,
> extends BaseMetadata {
ParentMetadata extends HookInvocationParentMetadata = HookInvocationParentMetadata,
>
extends BaseMetadata
implements InvocationMetadata
{
constructor(
context: MetadataContext,
public readonly definition: HookDefinitionMetadata,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import type { AggregatedIdentifier } from '../ids';
import type { InvocationMetadata } from '../types';
import { BaseMetadata } from './BaseMetadata';
import type { MetadataContext } from './MetadataContext';

import type { TestInvocationMetadata } from './TestInvocationMetadata';

export class TestFnInvocationMetadata extends BaseMetadata {
export class TestFnInvocationMetadata extends BaseMetadata implements InvocationMetadata {
constructor(
context: MetadataContext,
public readonly test: TestInvocationMetadata,
id: AggregatedIdentifier,
) {
super(context, id);
}

get definition() {
return this.test.entry;
}
}
4 changes: 4 additions & 0 deletions packages/library/src/metadata/types/Metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ export interface Metadata {
assign(path: undefined | string | readonly string[], value: Data): this;
merge(path: undefined | string | readonly string[], value: Data): this;
}

export interface InvocationMetadata {
readonly definition: Metadata;
}

0 comments on commit 7c97f42

Please sign in to comment.