Skip to content

Commit c43c559

Browse files
committed
Add a test to check the program address config renders as expected
1 parent 5565e44 commit c43c559

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

packages/renderers-js/test/instructionsPage.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,27 @@ test('it can override the import of a resolver value node', async () => {
397397
someModule: ['myResolver'],
398398
});
399399
});
400+
401+
test('it renders optional config that can override the program address', async () => {
402+
// Given the following instruction
403+
const node = programNode({
404+
instructions: [
405+
instructionNode({
406+
accounts: [],
407+
name: 'myInstruction',
408+
}),
409+
],
410+
name: 'myProgram',
411+
publicKey: '1111',
412+
});
413+
414+
// When we render it.
415+
const renderMap = visit(node, getRenderMapVisitor());
416+
417+
// Then we expect an optional config parameter with an optional programAddress field
418+
// And we expect this to be used to override programAddress if it is set
419+
await renderMapContains(renderMap, 'instructions/myInstruction.ts', [
420+
'config?: { programAddress?: Address }',
421+
'programAddress = config?.programAddress ?? MY_PROGRAM_PROGRAM_ADDRESS',
422+
]);
423+
});

0 commit comments

Comments
 (0)