1
1
import test from 'ava' ;
2
- import { expect } from 'chai' ;
3
2
import request from 'supertest' ;
4
- import app from '../server' ;
5
- import Post from '../models/ post' ;
6
- import { connectDB , dropDB } from '../util/test-helpers' ;
3
+ import app from '../../ server' ;
4
+ import Post from '../post' ;
5
+ import { connectDB , dropDB } from '../../ util/test-helpers' ;
7
6
8
7
// Initial posts added into test db
9
8
const posts = [
10
- new Post ( { name : 'Prashant' , title : 'Hello Mern' , cuid : 'f34gb2bh24b24b2' , content : "All cats meow 'mern!'" } ) ,
11
- new Post ( { name : 'Mayank' , title : 'Hi Mern' , cuid : 'f34gb2bh24b24b3' , content : "All dogs bark 'mern!'" } )
9
+ new Post ( { name : 'Prashant' , title : 'Hello Mern' , cuid : 'f34gb2bh24b24b2' , content : "All cats meow 'mern!'" } ) ,
10
+ new Post ( { name : 'Mayank' , title : 'Hi Mern' , cuid : 'f34gb2bh24b24b3' , content : "All dogs bark 'mern!'" } ) ,
12
11
] ;
13
12
14
13
test . beforeEach ( 'connect and add two post entries' , t => {
15
-
16
14
connectDB ( t , ( ) => {
17
15
Post . create ( posts , err => {
18
- if ( err ) t . fail ( 'Unable to create posts' ) ;
16
+ if ( err ) t . fail ( 'Unable to create posts' ) ;
19
17
} ) ;
20
18
} ) ;
21
19
} ) ;
@@ -38,7 +36,7 @@ test.serial('Should correctly give number of Posts', async t => {
38
36
test . serial ( 'Should send correct data when queried against a cuid' , async t => {
39
37
t . plan ( 2 ) ;
40
38
41
- var post = new Post ( { name : 'Foo' , title : 'bar' , slug : 'bar' , cuid : 'f34gb2bh24b24b2' , content : 'Hello Mern says Foo' } ) ;
39
+ const post = new Post ( { name : 'Foo' , title : 'bar' , slug : 'bar' , cuid : 'f34gb2bh24b24b2' , content : 'Hello Mern says Foo' } ) ;
42
40
post . save ( ) ;
43
41
44
42
const res = await request ( app )
0 commit comments