UNPKG

601 BJavaScriptView Raw
1import test from 'ava';
2import sut from './server';
3import request from 'supertest-as-promised';
4import mongoose from 'mongoose';
5import mockgoose from 'mockgoose';
6
7test.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
15test('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
20test.after(t => mockgoose.reset(err => {
21 if (err) t.fail(err)
22}));