Skip to content

Commit

Permalink
Fix stop server failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhddev committed Oct 16, 2023
1 parent 8f3b70c commit 0b04c1d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/test/server_app/server/Server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,31 @@ describe('Server test suite', ()=>{
});

it('should stop the server if started',async ()=>{
serverMock.close.mockImplementationOnce((cb: Function)=>{
cb();
})

await sut.startServer();

await sut.stopServer();

expect(serverMock.close).toBeCalledTimes(1);
})

it('should forward error while stopping server',async ()=>{
serverMock.close.mockImplementationOnce((cb: Function)=>{
cb(new Error('Error while closing server!'));
})

await sut.startServer();

expect(async ()=>{
await sut.stopServer();
}).rejects.toThrowError('Error while closing server!')

expect(serverMock.close).toBeCalledTimes(1);
})



})

0 comments on commit 0b04c1d

Please sign in to comment.