1- import { jest } from ' @jest/globals' ;
2- import request from ' supertest' ;
3- import app from ' #app' ; // Update this import based on your app' s structure
4- import connector from ' #models/databaseUtil' ; // Update this import
5- import infrastructureModel from ' #models/infrastructure' ; // Update this import
1+ import { jest } from " @jest/globals" ; // eslint-disable-line import/no-extraneous-dependencies
2+ import request from " supertest" ;
3+ import app from " #app" ; // Update this import based on your app" s structure
4+ import connector from " #models/databaseUtil" ; // Update this import
5+ import infrastructureModel from " #models/infrastructure" ; // Update this import
66
7- jest . mock ( ' #util' ) ;
7+ jest . mock ( " #util" ) ;
88
99let server ;
1010let agent ;
1111
1212beforeAll ( ( done ) => {
1313 server = app . listen ( 5000 , ( ) => {
1414 agent = request . agent ( server ) ;
15- connector . set ( ' debug' , false ) ;
15+ connector . set ( " debug" , false ) ;
1616 done ( ) ;
1717 } ) ;
1818} ) ;
1919
2020function cleanUp ( callback ) {
2121 infrastructureModel
2222 . remove ( {
23- name : ' Building A' ,
24- type : ' Office' ,
25- wing : ' East' ,
23+ name : " Building A" ,
24+ type : " Office" ,
25+ wing : " East" ,
2626 floor : 3 ,
2727 capacity : 100 ,
2828 } )
2929 . then ( ( ) => {
3030 connector . disconnect ( ( DBerr ) => {
31- if ( DBerr ) console . log ( ' Database disconnect error: ' , DBerr ) ;
31+ if ( DBerr ) console . log ( " Database disconnect error: " , DBerr ) ;
3232 server . close ( ( serverErr ) => {
3333 if ( serverErr ) console . log ( serverErr ) ;
3434 callback ( ) ;
@@ -41,12 +41,12 @@ afterAll((done) => {
4141 cleanUp ( done ) ;
4242} ) ;
4343
44- describe ( ' Infrastructure API' , ( ) => {
45- it ( ' should create infrastructure' , async ( ) => {
46- const response = await agent . post ( ' /infrastructure/add' ) . send ( {
47- name : ' Building A' ,
48- type : ' Office' ,
49- wing : ' East' ,
44+ describe ( " Infrastructure API" , ( ) => {
45+ it ( " should create infrastructure" , async ( ) => {
46+ const response = await agent . post ( " /infrastructure/add" ) . send ( {
47+ name : " Building A" ,
48+ type : " Office" ,
49+ wing : " East" ,
5050 floor : 3 ,
5151 capacity : 100 ,
5252 } ) ;
@@ -55,38 +55,38 @@ describe('Infrastructure API', () => {
5555 expect ( response . body . res ) . toMatch ( / a d d e d u s e r / ) ;
5656 } ) ;
5757
58- describe ( ' after adding infrastructure' , ( ) => {
58+ describe ( " after adding infrastructure" , ( ) => {
5959 beforeEach ( async ( ) => {
60- await agent . post ( ' /infrastructure/add' ) . send ( {
61- name : ' Building A' ,
62- type : ' Office' ,
63- wing : ' East' ,
60+ await agent . post ( " /infrastructure/add" ) . send ( {
61+ name : " Building A" ,
62+ type : " Office" ,
63+ wing : " East" ,
6464 floor : 3 ,
6565 capacity : 100 ,
6666 } ) ;
6767 } ) ;
6868
6969 afterEach ( async ( ) => {
7070 await infrastructureModel . remove ( {
71- name : ' Building A' ,
72- type : ' Office' ,
73- wing : ' East' ,
71+ name : " Building A" ,
72+ type : " Office" ,
73+ wing : " East" ,
7474 floor : 3 ,
7575 capacity : 100 ,
7676 } ) ;
7777 } ) ;
7878
79- it ( ' should read infrastructure' , async ( ) => {
79+ it ( " should read infrastructure" , async ( ) => {
8080 const response = await agent
81- . post ( ' /infrastructure/list' )
82- . send ( { name : ' Building A' } ) ;
81+ . post ( " /infrastructure/list" )
82+ . send ( { name : " Building A" } ) ;
8383 expect ( response . body . res ) . not . toBeNull ( ) ;
8484 } ) ;
8585
86- it ( ' should update infrastructure' , async ( ) => {
86+ it ( " should update infrastructure" , async ( ) => {
8787 const response = await agent
88- . post ( ' /infrastructure/update' )
89- . send ( { name : ' Building A' } , { capacity : 150 } ) ;
88+ . post ( " /infrastructure/update" )
89+ . send ( { name : " Building A" } , { capacity : 150 } ) ;
9090
9191 expect ( response . status ) . toBe ( 200 ) ;
9292 expect ( response . body . res ) . toMatch ( / u p d a t e d i n f r a s t r u c t u r e / ) ;
0 commit comments