1- import request from ' supertest' ;
2- import { jest } from ' @jest/globals' ; // eslint-disable-line import/no-extraneous-dependencies
3- import app from ' #app' ;
4- import accreditationModel from ' #models/accreditation' ;
5- import connector from ' #models/databaseUtil' ;
1+ import request from " supertest" ;
2+ import { jest } from " @jest/globals" ; // eslint-disable-line import/no-extraneous-dependencies
3+ import app from " #app" ;
4+ import accreditationModel from " #models/accreditation" ;
5+ import connector from " #models/databaseUtil" ;
66
7- jest . mock ( ' #util' ) ;
7+ jest . mock ( " #util" ) ;
88
99let server ;
1010let agent ;
1111beforeAll ( ( done ) => {
1212 server = app . listen ( 5000 , ( ) => {
1313 agent = request . agent ( server ) ;
14- connector . set ( ' debug' , false ) ;
14+ connector . set ( " debug" , false ) ;
1515 done ( ) ;
1616 } ) ;
1717} ) ;
1818
1919function cleanUp ( callback ) {
20- accreditationModel . remove ( { name : ' xyz' } ) . then ( ( ) => {
20+ accreditationModel . remove ( { name : " xyz" } ) . then ( ( ) => {
2121 connector . disconnect ( ( DBerr ) => {
22- if ( DBerr ) console . log ( ' Database dissconnnect error: ' , DBerr ) ;
22+ if ( DBerr ) console . log ( " Database dissconnnect error: " , DBerr ) ;
2323 server . close ( ( serverErr ) => {
2424 if ( serverErr ) console . log ( serverErr ) ;
2525 callback ( ) ;
@@ -32,44 +32,44 @@ afterAll((done) => {
3232 cleanUp ( done ) ;
3333} ) ;
3434
35- describe ( ' checking accreditation functions' , ( ) => {
36- it ( ' create accreditation' , async ( ) => {
37- const response = await agent . post ( ' /accreditation/add' ) . send ( {
38- name : ' xyz' ,
39- agencyName : ' abc' ,
40- dateofAccreditation : ' 2023-06-18T14:11:30Z' ,
41- dateofExpiry : ' 2023-05-28T14:10:30Z' ,
35+ describe ( " checking accreditation functions" , ( ) => {
36+ it ( " create accreditation" , async ( ) => {
37+ const response = await agent . post ( " /accreditation/add" ) . send ( {
38+ name : " xyz" ,
39+ agencyName : " abc" ,
40+ dateofAccreditation : " 2023-06-18T14:11:30Z" ,
41+ dateofExpiry : " 2023-05-28T14:10:30Z" ,
4242 } ) ;
43- expect ( response . headers [ ' content-type' ] ) . toMatch ( / j s o n / ) ;
43+ expect ( response . headers [ " content-type" ] ) . toMatch ( / j s o n / ) ;
4444 expect ( response . status ) . toBe ( 200 ) ;
4545 expect ( response . body . res ) . toMatch ( / a d d e d a c c r e d i t a t i o n / ) ;
4646 } ) ;
4747
4848 beforeEach ( async ( ) => {
49- agent . post ( ' /accreditation/add' ) . send ( {
50- name : ' xyz' ,
51- agencyName : ' abc' ,
52- dateofAccreditation : ' 2023-06-18T14:11:30Z' ,
53- dateofExpiry : ' 2023-05-28T14:10:30Z' ,
49+ agent . post ( " /accreditation/add" ) . send ( {
50+ name : " xyz" ,
51+ agencyName : " abc" ,
52+ dateofAccreditation : " 2023-06-18T14:11:30Z" ,
53+ dateofExpiry : " 2023-05-28T14:10:30Z" ,
5454 } ) ;
5555 } ) ;
5656
5757 afterEach ( async ( ) => {
58- await accreditationModel . remove ( { name : ' xyz' } ) ;
58+ await accreditationModel . remove ( { name : " xyz" } ) ;
5959 } ) ;
6060
61- it ( ' read accreditation' , async ( ) => {
61+ it ( " read accreditation" , async ( ) => {
6262 const response = await agent
63- . post ( ' /accreditation/list' )
64- . send ( { name : ' xyz' } ) ;
63+ . post ( " /accreditation/list" )
64+ . send ( { name : " xyz" } ) ;
6565 expect ( response . body . res ) . not . toBeNull ( ) ;
6666 } ) ;
6767
68- it ( ' update accreditation' , async ( ) => {
68+ it ( " update accreditation" , async ( ) => {
6969 const response = await agent
70- . post ( ' /accreditation/update' )
71- . send ( { name : ' xyz' } , { name : ' 123' } ) ;
72- expect ( response . headers [ ' content-type' ] ) . toMatch ( / j s o n / ) ;
70+ . post ( " /accreditation/update" )
71+ . send ( { name : " xyz" } , { name : " 123" } ) ;
72+ expect ( response . headers [ " content-type" ] ) . toMatch ( / j s o n / ) ;
7373 expect ( response . status ) . toBe ( 200 ) ;
7474 expect ( response . body . res ) . toMatch ( / a c c r e d i t a t i o n u p d a t e d / ) ;
7575 } ) ;
0 commit comments