summaryrefslogtreecommitdiff
path: root/test/note.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/note.ts')
-rw-r--r--test/note.ts29
1 files changed, 9 insertions, 20 deletions
diff --git a/test/note.ts b/test/note.ts
index 4a4a777340..3aa12b5a61 100644
--- a/test/note.ts
+++ b/test/note.ts
@@ -16,9 +16,9 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert';
import * as childProcess from 'child_process';
-import { async, signup, request, post, uploadFile } from './utils';
-import { Note } from '../built/models/entities/note';
-const initDb = require('../built/db/postgre.js').initDb;
+import { async, signup, request, post, uploadFile, launchServer } from './utils';
+import { Note } from '../src/models/entities/note';
+import { initDb } from '../src/db/postgre';
describe('Note', () => {
let p: childProcess.ChildProcess;
@@ -27,23 +27,12 @@ describe('Note', () => {
let alice: any;
let bob: any;
- before(done => {
- p = childProcess.spawn('node', [__dirname + '/../index.js'], {
- stdio: ['inherit', 'inherit', 'ipc'],
- env: { NODE_ENV: 'test' }
- });
- p.on('message', message => {
- if (message === 'ok') {
- (p.channel as any).onread = () => {};
- initDb(true).then(async connection => {
- Notes = connection.getRepository(Note);
- alice = await signup({ username: 'alice' });
- bob = await signup({ username: 'bob' });
- done();
- });
- }
- });
- });
+ before(launchServer(g => p = g, async () => {
+ const connection = await initDb(true);
+ Notes = connection.getRepository(Note);
+ alice = await signup({ username: 'alice' });
+ bob = await signup({ username: 'bob' });
+ }));
after(() => {
p.kill();