Skip to content

Commit ad3a466

Browse files
committed
Add test
1 parent dbc90a2 commit ad3a466

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

packages/renderers-rust/test/accountsPage.test.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { visit } from '@codama/visitors-core';
1717
import { test } from 'vitest';
1818

1919
import { getRenderMapVisitor } from '../src';
20-
import { codeContains } from './_setup';
20+
import { codeContains, codeDoesNotContains } from './_setup';
2121

2222
test('it renders a byte array seed used on an account', () => {
2323
// Given the following program with 1 account and 1 pda with a byte array as seeds.
@@ -134,3 +134,33 @@ test('it renders anchor traits impl', () => {
134134
'impl anchor_lang::Owner for TestAccount',
135135
]);
136136
});
137+
138+
test('it renders account without anchor traits', () => {
139+
// Given the following account.
140+
const node = programNode({
141+
accounts: [
142+
accountNode({
143+
discriminators: [
144+
{
145+
kind: 'fieldDiscriminatorNode',
146+
name: camelCase('discriminator'),
147+
offset: 0,
148+
},
149+
],
150+
name: 'testAccount',
151+
pda: pdaLinkNode('testPda'),
152+
}),
153+
],
154+
name: 'myProgram',
155+
publicKey: '1111',
156+
});
157+
158+
// When we render it with anchor traits disabled.
159+
const renderMap = visit(node, getRenderMapVisitor({ anchorTraits: false }));
160+
161+
// Then we do not expect Anchor traits.
162+
codeDoesNotContains(renderMap.get('accounts/test_account.rs'), [
163+
'#[cfg(feature = "anchor")]',
164+
'#[cfg(feature = "anchor-idl-build")]',
165+
]);
166+
});

0 commit comments

Comments
 (0)