1 | import test from 'ava';
|
2 | import sut from './server';
|
3 | import request from 'supertest-as-promised';
|
4 | import mongoose from 'mongoose';
|
5 | import mockgoose from 'mockgoose';
|
6 |
|
7 | test.before(async t => {
|
8 | console.log('1');
|
9 | await mockgoose(mongoose);
|
10 | console.log('2');
|
11 | const Subscription = mongoose.model('Subscription');
|
12 | await Subscription.create({ id: 'found' })
|
13 | });
|
14 |
|
15 | test('send message to an existent subscription', async t => {
|
16 | const res = await request(sut).post('/api/found/message');
|
17 | t.is(res.status, 200);
|
18 | });
|
19 |
|
20 | test.after(t => mockgoose.reset(err => {
|
21 | if (err) t.fail(err)
|
22 | }));
|