@@ -99,3 +99,48 @@ test('it fails to add a PDA if its name conflicts with an existing PDA on the pr
9999 } ) ,
100100 ) ;
101101} ) ;
102+
103+ test ( 'it adds PDA nodes to a program with docs' , ( ) => {
104+ // Given a program with a single PDA.
105+ const node = programNode ( {
106+ name : 'myProgram' ,
107+ pdas : [
108+ pdaNode ( {
109+ name : 'associatedToken' ,
110+ seeds : [
111+ variablePdaSeedNode ( 'owner' , publicKeyTypeNode ( ) ) ,
112+ constantPdaSeedNodeFromProgramId ( ) ,
113+ variablePdaSeedNode ( 'mint' , publicKeyTypeNode ( ) ) ,
114+ ] ,
115+ } ) ,
116+ ] ,
117+ publicKey : 'Epo9rxh99jpeeWabRZi4tpgUVxZQeVn9vbbDjUztJtu4' ,
118+ } ) ;
119+
120+ // When we add two more PDAs.
121+ const newPdas = [
122+ pdaNode ( {
123+ docs : 'Metadata for a token.' ,
124+ name : 'metadata' ,
125+ seeds : [
126+ constantPdaSeedNodeFromString ( 'utf8' , 'metadata' ) ,
127+ constantPdaSeedNodeFromProgramId ( ) ,
128+ variablePdaSeedNode ( 'mint' , publicKeyTypeNode ( ) ) ,
129+ ] ,
130+ } ) ,
131+ pdaNode ( {
132+ docs : 'The master edition.' ,
133+ name : 'masterEdition' ,
134+ seeds : [
135+ constantPdaSeedNodeFromString ( 'utf8' , 'metadata' ) ,
136+ constantPdaSeedNodeFromProgramId ( ) ,
137+ variablePdaSeedNode ( 'mint' , publicKeyTypeNode ( ) ) ,
138+ constantPdaSeedNodeFromString ( 'utf8' , 'edition' ) ,
139+ ] ,
140+ } ) ,
141+ ] ;
142+ const result = visit ( node , addPdasVisitor ( { myProgram : newPdas } ) ) ;
143+
144+ // Then we expect the following program to be returned.
145+ expect ( result ) . toEqual ( { ...node , pdas : [ ...node . pdas , ...newPdas ] } ) ;
146+ } ) ;
0 commit comments