From 676c5b350ccc7b32eb770193135bc210b6d02085 Mon Sep 17 00:00:00 2001 From: David Thyresson Date: Mon, 28 Nov 2022 15:04:27 -0500 Subject: [PATCH] Make it clearer that can use directiveArgs in transformer directive (#6497) Co-authored-by: Daniel Choudhury --- packages/testing/src/api/directive.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/testing/src/api/directive.ts b/packages/testing/src/api/directive.ts index 61128c631b0c..3619ba2e8911 100644 --- a/packages/testing/src/api/directive.ts +++ b/packages/testing/src/api/directive.ts @@ -39,6 +39,7 @@ interface DirectiveMocker { * * - Transformer directives can be passed mockedResolvedValue * - Validator directives should check for errors thrown in certain situations + * - Can provide args, directiveArgs and context to mock directive execution * * @example * @@ -72,7 +73,7 @@ export const mockRedwoodDirective: DirectiveMocker = ( directive, executionMock ) => { - const { directiveArgs = {}, context, ...others } = executionMock + const { directiveArgs, context, ...others } = executionMock if (context) { setContext(context || {}) @@ -85,12 +86,13 @@ export const mockRedwoodDirective: DirectiveMocker = ( return directive.onResolvedValue({ resolvedValue: mockedResolvedValue, context: globalContext, + directiveArgs: directiveArgs || {}, ...others, } as DirectiveParams) } else { await directive.onResolvedValue({ context: globalContext, - directiveArgs, + directiveArgs: directiveArgs || {}, ...others, } as DirectiveParams) } @@ -103,13 +105,13 @@ export const mockRedwoodDirective: DirectiveMocker = ( return directive.onResolvedValue({ resolvedValue: mockedResolvedValue, context: globalContext, - directiveArgs, + directiveArgs: directiveArgs || {}, ...others, } as DirectiveParams) } else { directive.onResolvedValue({ context: globalContext, - directiveArgs, + directiveArgs: directiveArgs || {}, ...others, } as DirectiveParams) }