-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: captain-Akshay <[email protected]>
- Loading branch information
1 parent
eb67a75
commit bc20408
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { expect } from 'chai'; | ||
|
||
import { config } from '../src/config.js'; | ||
import { DwnServer } from '../src/dwn-server.js'; | ||
import { clear, dwn } from './test-dwn.js'; | ||
|
||
describe('DwnServer', function () { | ||
let dwnServer: DwnServer; | ||
const options = { | ||
dwn: dwn, | ||
config: config, | ||
}; | ||
before(function () { | ||
dwnServer = new DwnServer(options); | ||
}); | ||
after(async function () { | ||
dwnServer.stop(() => console.log('server stop')); | ||
await clear(); | ||
}); | ||
it('should create an instance of DwnServer', function () { | ||
expect(dwnServer).to.be.an.instanceOf(DwnServer); | ||
}); | ||
|
||
it('should start the server and listen on the specified port', async function () { | ||
await dwnServer.start(); | ||
const response = await fetch('http://localhost:3000', { | ||
method: 'GET', | ||
}); | ||
expect(response.status).to.equal(200); | ||
}); | ||
it('should stop the server', async function () { | ||
dwnServer.stop(() => console.log('server Stop')); | ||
// Add an assertion to check that the server has been stopped | ||
expect(dwnServer.httpServer.listening).to.be.false; | ||
}); | ||
}); |