Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added test for dwn-server #75

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions tests/dwn-server.spec.ts
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;
});
});
Loading