@@ -52,7 +52,7 @@ describe('File modification calculator tests', () => {
5252 const result = await calculator . calculate ( [ {
5353 modification : ModificationType . INSERT_OR_UPDATE ,
5454 resource : modifiedResource ,
55- } ] )
55+ } ] , match )
5656
5757 console . log ( result )
5858 console . log ( result . diff )
@@ -89,7 +89,7 @@ describe('File modification calculator tests', () => {
8989 const result = await calculator . calculate ( [ {
9090 modification : ModificationType . DELETE ,
9191 resource : modifiedResource ,
92- } ] )
92+ } ] , match )
9393
9494 expect ( result . newFile ) . to . eq ( '[\n' +
9595 ' {\n' +
@@ -134,7 +134,7 @@ describe('File modification calculator tests', () => {
134134 const result = await calculator . calculate ( [ {
135135 modification : ModificationType . DELETE ,
136136 resource : modifiedResource ,
137- } ] )
137+ } ] , match )
138138
139139 expect ( result . newFile ) . to . eq ( '[\n' +
140140 ' {\n' +
@@ -175,7 +175,7 @@ describe('File modification calculator tests', () => {
175175 const result = await calculator . calculate ( [ {
176176 modification : ModificationType . DELETE ,
177177 resource : modifiedResource ,
178- } ] )
178+ } ] , match )
179179
180180 expect ( result . newFile ) . to . eq ( '[\n' +
181181 ' { "type": "resource2", "param2": ["a", "b", "c"] },\n' +
@@ -221,7 +221,7 @@ describe('File modification calculator tests', () => {
221221 const result = await calculator . calculate ( [ {
222222 modification : ModificationType . INSERT_OR_UPDATE ,
223223 resource : modifiedResource ,
224- } ] )
224+ } ] , match )
225225
226226 expect ( result . newFile ) . to . eq ( '[\n' +
227227 ' {\n' +
@@ -298,7 +298,7 @@ describe('File modification calculator tests', () => {
298298 const result = await calculator . calculate ( [ {
299299 modification : ModificationType . INSERT_OR_UPDATE ,
300300 resource : modifiedResource ,
301- } ] )
301+ } ] , match )
302302
303303 expect ( result . newFile ) . to . eq ( '[\n' +
304304 ' {\n' +
@@ -356,7 +356,7 @@ describe('File modification calculator tests', () => {
356356 const result = await calculator . calculate ( [ {
357357 modification : ModificationType . INSERT_OR_UPDATE ,
358358 resource : modifiedResource ,
359- } ] )
359+ } ] , match )
360360
361361 expect ( result . newFile ) . to . eq ( '[\n' +
362362 ' {\n' +
@@ -415,7 +415,7 @@ describe('File modification calculator tests', () => {
415415 } , {
416416 modification : ModificationType . INSERT_OR_UPDATE ,
417417 resource : modifiedResource2 ,
418- } ] )
418+ } ] , match )
419419
420420 expect ( result . newFile ) . to . eq ( '[\n' +
421421 ' {\n' +
@@ -491,7 +491,7 @@ describe('File modification calculator tests', () => {
491491 const result = await calculator . calculate ( [ {
492492 modification : ModificationType . INSERT_OR_UPDATE ,
493493 resource : modifiedResource ,
494- } ] )
494+ } ] , match )
495495
496496 // TODO: The result is currently wrong need to fix
497497 console . log ( result ) ;
@@ -522,6 +522,10 @@ describe('File modification calculator tests', () => {
522522 } )
523523} )
524524
525+ async function match ( resource : ResourceConfig , array : ResourceConfig [ ] ) : Promise < number > {
526+ return array . findIndex ( ( r ) => resource . isSame ( r . type , r . name ) ) ;
527+ }
528+
525529function generateResourceInfo ( type : string , requiredParameters ?: string [ ] ) : ResourceInfo {
526530 return ResourceInfo . fromResponseData ( {
527531 plugin : 'plugin' ,
0 commit comments