Skip to content

Commit 4567d92

Browse files
committed
Add isSigner either test to JS renderer
1 parent 4bc5823 commit 4567d92

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
argumentValueNode,
3+
instructionAccountNode,
34
instructionArgumentNode,
45
instructionNode,
56
numberTypeNode,
@@ -12,6 +13,28 @@ import { test } from 'vitest';
1213
import { getRenderMapVisitor } from '../src';
1314
import { codeContains, codeDoesNotContain, renderMapContains } from './_setup';
1415

16+
test('it renders instruction accounts that can either be signer or non-signer', async () => {
17+
// Given the following instruction with a signer or non-signer account.
18+
const node = programNode({
19+
instructions: [
20+
instructionNode({
21+
accounts: [instructionAccountNode({ isSigner: 'either', isWritable: false, name: 'myAccount' })],
22+
name: 'myInstruction',
23+
}),
24+
],
25+
name: 'myProgram',
26+
publicKey: '1111',
27+
});
28+
29+
// When we render it.
30+
const renderMap = visit(node, getRenderMapVisitor());
31+
32+
// Then we expect the input to be rendered as either a signer or non-signer.
33+
await renderMapContains(renderMap, 'instructions/myInstruction.ts', [
34+
'myAccount: Address<TAccountMyAccount> | TransactionSigner<TAccountMyAccount>;',
35+
]);
36+
});
37+
1538
test('it renders extra arguments that default on each other', async () => {
1639
// Given the following instruction with two extra arguments
1740
// such that one defaults to the other.

0 commit comments

Comments
 (0)