This commit is contained in:
syuilo 2019-01-23 13:35:22 +09:00
parent 931f17c589
commit 4d24741d48
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
3 changed files with 24 additions and 4 deletions

View File

@ -101,6 +101,19 @@ function createServer() {
}
}
// For testing
export const startServer = () => {
const server = createServer();
// Init stream server
require('./api/streaming')(server);
// Listen
server.listen(config.port);
return server;
};
export default () => new Promise(resolve => {
const server = createServer();

View File

@ -27,7 +27,6 @@ process.on('unhandledRejection', console.dir);
//#endregion
const app = require('../built/server/api').default;
require('../built/server').default();
const db = require('../built/db/mongodb').default;
const server = http.createServer(app.callback());
@ -44,6 +43,10 @@ describe('API', () => {
// Reset database each test
beforeEach(resetDb(db));
before(() => {
server.close();
});
describe('signup', () => {
it('不正なユーザー名でアカウントが作成できない', async(async () => {
const res = await request('/signup', {

View File

@ -27,13 +27,13 @@ process.on('unhandledRejection', console.dir);
//#endregion
const app = require('../built/server/api').default;
require('../built/server').default();
const server = require('../built/server').startServer();
const db = require('../built/db/mongodb').default;
const server = http.createServer(app.callback());
const apiServer = http.createServer(app.callback());
//#region Utilities
const request = _request(server);
const request = _request(apiServer);
const signup = _signup(request);
//#endregion
@ -41,6 +41,10 @@ describe('Streaming', () => {
// Reset database each test
beforeEach(resetDb(db));
before(() => {
server.close();
});
it('投稿がタイムラインに流れる', done => {
const post = {
text: 'foo'