@@ -30,14 +30,20 @@ describe('Custom Bindings', () =>
3030
3131 // Omitting non-optional parameter should throw
3232 expect ( ( ) => { nodeGraph . addNode ( ) ; } ) . to . throw ;
33+
34+ // Cleanup
35+ node . delete ( ) ;
36+ nodeGraph2 . delete ( ) ;
37+ nodeGraph . delete ( ) ;
38+ doc . delete ( ) ;
3339 } ) ;
3440
3541 it ( 'Vector <-> Array conversion' , ( ) =>
3642 {
3743 // Functions that return vectors in C++ should return an array in JS
3844 const doc = mx . createDocument ( ) ;
3945 const nodeGraph = doc . addNodeGraph ( ) ;
40- doc . addNodeGraph ( ) ;
46+ const nodeGraphB = doc . addNodeGraph ( ) ;
4147 const nodeGraphs = doc . getNodeGraphs ( ) ;
4248 expect ( nodeGraphs ) . to . be . an . instanceof ( Array ) ;
4349 expect ( nodeGraphs . length ) . to . equal ( 2 ) ;
@@ -68,6 +74,16 @@ describe('Custom Bindings', () =>
6874 expect ( nodes [ 0 ] . getName ( ) ) . to . equal ( 'node1' ) ; // Name auto-constructed from category
6975 expect ( nodes [ 1 ] . getName ( ) ) . to . equal ( 'node2' ) ; // Name auto-constructed from category
7076 expect ( nodes [ 2 ] . getName ( ) ) . to . equal ( 'anotherNode' ) ; // Name set explicitly at creation time
77+
78+ // Cleanup created wrappers
79+ nodes . forEach ( n => n . delete ( ) ) ;
80+ backdrop . delete ( ) ;
81+ node3 . delete ( ) ;
82+ node2 . delete ( ) ;
83+ node1 . delete ( ) ;
84+ nodeGraphB . delete ( ) ;
85+ nodeGraph . delete ( ) ;
86+ doc . delete ( ) ;
7187 } ) ;
7288
7389 it ( 'C++ exception handling' , ( ) =>
@@ -81,17 +97,20 @@ describe('Custom Bindings', () =>
8197 expect ( nodeGraph1 . hasInheritanceCycle ( ) ) . to . not . throw ;
8298 expect ( nodeGraph1 . hasInheritanceCycle ( ) ) . to . be . true ;
8399
84- // Exceptions that are not caught in C++ should throw with an exception pointer
100+ // Exceptions that are not caught in C++ should throw
85101 nodeGraph1 . addNode ( 'node' , 'node1' ) ;
86102 expect ( ( ) => { nodeGraph1 . addNode ( 'node' , 'node1' ) ; } ) . to . throw ;
87103 try
88104 {
89105 nodeGraph1 . addNode ( 'node' , 'node1' ) ;
90- } catch ( errPtr )
106+ } catch ( err )
91107 {
92- expect ( errPtr ) . to . be . a ( 'number' ) ;
93- expect ( mx . getExceptionMessage ( errPtr ) ) . to . be . a ( 'string' ) ;
108+ expect ( mx . getExceptionMessage ( err ) ) . to . be . a ( 'string' ) ;
94109 }
110+ // Cleanup
111+ nodeGraph2 . delete ( ) ;
112+ nodeGraph1 . delete ( ) ;
113+ doc . delete ( ) ;
95114 } ) ;
96115
97116 it ( 'getReferencedSourceUris' , async ( ) =>
@@ -104,6 +123,7 @@ describe('Custom Bindings', () =>
104123 expect ( sourceUris . length ) . to . equal ( 3 ) ;
105124 expect ( sourceUris [ 0 ] ) . to . be . a ( 'string' ) ;
106125 expect ( sourceUris . includes ( 'standard_surface_brass_tiled.mtlx' ) ) . to . be . true ;
126+ doc . delete ( ) ;
107127 } ) ;
108128
109129 it ( 'Should invoke correct instance of \'validate\'' , ( ) =>
@@ -133,6 +153,11 @@ describe('Custom Bindings', () =>
133153 expect ( token . validate ( ) ) . to . be . false ;
134154 expect ( token . validate ( message ) ) . to . be . false ;
135155 expect ( message . message ) . to . include ( 'Unit type definition does not exist in document' )
156+
157+ // Cleanup
158+ token . delete ( ) ;
159+ node . delete ( ) ;
160+ doc . delete ( ) ;
136161 } ) ;
137162
138163 it ( 'StringResolver name substitution getters' , ( ) =>
@@ -164,6 +189,7 @@ describe('Custom Bindings', () =>
164189 expect ( gnSubs ) . to . be . instanceof ( Object ) ;
165190 expect ( Object . keys ( gnSubs ) . length ) . to . equal ( 2 ) ;
166191 expect ( gnSubs ) . to . deep . equal ( gnTestData ) ;
192+ resolver . delete ( ) ;
167193 } ) ;
168194
169195 it ( 'getShaderNodes' , async ( ) =>
@@ -184,6 +210,11 @@ describe('Custom Bindings', () =>
184210 shaderNodes = mx . getShaderNodes ( matNode , mx . DISPLACEMENT_SHADER_TYPE_STRING ) ;
185211 expect ( shaderNodes ) . to . be . instanceof ( Array ) ;
186212 expect ( shaderNodes . length ) . to . equal ( 0 ) ;
213+
214+ // Cleanup wrappers
215+ shaderNodes . forEach ( s => s . delete ( ) ) ;
216+ matNodes . forEach ( n => n . delete ( ) ) ;
217+ doc . delete ( ) ;
187218 } ) ;
188219
189220 it ( 'createValidName' , ( ) =>
@@ -211,6 +242,7 @@ describe('Custom Bindings', () =>
211242 expect ( docVersion ) . to . be . instanceof ( Array ) ;
212243 expect ( docVersion . length ) . to . equal ( 2 ) ;
213244 expect ( docVersion ) . to . deep . equal ( versionStringArr ) ;
245+ doc . delete ( ) ;
214246
215247 // InterfaceElement.getVersionIntegers (via NodeDef)
216248 // TODO: This function can currently not be called, since we have a linker issue that messes up this function.
0 commit comments