1- import infrastructureController from '../controllers/infrastructure' ;
1+ import { addinfrastructure } from '../controllers/infrastructure' ;
22
33describe ( 'Infrastructure Controller' , ( ) => {
44 const mockInfrastructure = {
@@ -10,10 +10,12 @@ describe('Infrastructure Controller', () => {
1010 } ;
1111
1212 it ( 'should add infrastructure' , async ( ) => {
13- const createSpy = jest . spyOn ( infrastructureController , 'create' ) ;
13+ const createSpy = jest . spyOn ( addinfrastructure , 'create' ) ;
1414 createSpy . mockResolvedValue ( mockInfrastructure ) ;
1515
16- const result = await infrastructureController . addInfrastructure ( mockInfrastructure ) ;
16+ const result = await addinfrastructure . addInfrastructure (
17+ mockInfrastructure
18+ ) ;
1719 expect ( result ) . toEqual ( mockInfrastructure ) ;
1820 expect ( createSpy ) . toHaveBeenCalledWith (
1921 mockInfrastructure . name ,
@@ -27,10 +29,10 @@ describe('Infrastructure Controller', () => {
2729 it ( 'should read infrastructure' , async ( ) => {
2830 const filter = { name : 'Building A' } ;
2931 const limit = 5 ;
30- const readSpy = jest . spyOn ( infrastructureController , 'read' ) ;
32+ const readSpy = jest . spyOn ( addinfrastructure , 'read' ) ;
3133 readSpy . mockResolvedValue ( [ mockInfrastructure ] ) ;
3234
33- const result = await infrastructureController . readInfrastructure ( filter , limit ) ;
35+ const result = await addinfrastructure . readInfrastructure ( filter , limit ) ;
3436 expect ( result ) . toEqual ( [ mockInfrastructure ] ) ;
3537 expect ( readSpy ) . toHaveBeenCalledWith ( filter , limit ) ;
3638 } ) ;
@@ -39,21 +41,24 @@ describe('Infrastructure Controller', () => {
3941 const filter = { name : 'Building A' } ;
4042 const updateData = { capacity : 150 } ;
4143 const updatedInfrastructure = { ...mockInfrastructure , capacity : 150 } ;
42- const updateSpy = jest . spyOn ( infrastructureController , 'update' ) ;
44+ const updateSpy = jest . spyOn ( addinfrastructure , 'update' ) ;
4345 updateSpy . mockResolvedValue ( updatedInfrastructure ) ;
4446
45- const result = await infrastructureController . updateInfrastructure ( filter , updateData ) ;
47+ const result = await addinfrastructure . updateInfrastructure (
48+ filter ,
49+ updateData
50+ ) ;
4651 expect ( result ) . toEqual ( updatedInfrastructure ) ;
4752 expect ( updateSpy ) . toHaveBeenCalledWith ( filter , updateData ) ;
4853 } ) ;
4954
5055 it ( 'should remove infrastructure' , async ( ) => {
5156 const filter = { name : 'Building A' } ;
5257 const removedInfrastructure = { ...mockInfrastructure } ;
53- const removeSpy = jest . spyOn ( infrastructureController , 'remove' ) ;
58+ const removeSpy = jest . spyOn ( addinfrastructure , 'remove' ) ;
5459 removeSpy . mockResolvedValue ( removedInfrastructure ) ;
5560
56- const result = await infrastructureController . removeInfrastructure ( filter ) ;
61+ const result = await addinfrastructure . removeInfrastructure ( filter ) ;
5762 expect ( result ) . toEqual ( removedInfrastructure ) ;
5863 expect ( removeSpy ) . toHaveBeenCalledWith ( filter ) ;
5964 } ) ;
0 commit comments