1+ import { server } from '../app'
2+ import axios from 'axios'
3+ // axios.defaults.baseURL = `http://localhost:4000`
4+ import MockAdapter from 'axios-mock-adapter' ;
5+ // const baseUrl = `http://localhost:4000`
6+ const mock = new MockAdapter ( axios ) ;
7+
8+ //After all the tests are done we're going to close our server
9+ //and rollback our database.
10+ afterAll ( async ( ) => {
11+ //This closes the app but it doesn't stop the tests in
12+ //Jest when done - that's why we have to --forceExit
13+ //when running Jest for now.
14+ return server . close ( )
15+ } ) ;
16+
17+ describe ( 'user account actions' , ( ) => {
18+
19+ it ( 'signs up a user' , async ( ) => {
20+ mock . onPost ( '/api/v1/user/signup' ) . reply ( function ( ) {
21+ return [ 200 , { foo : 'bar' } ] ;
22+ } ) ;
23+
24+ // axios.get('/foo1')
25+ // .then(function(response) {
26+ // console.log(response.data);
27+ // expect(response.status).toBe(200)
28+ // })
29+ // .catch(function(error) {
30+ // throw new Error(error)
31+ // })
32+
33+
34+ expect . assertions ( 1 )
35+ const response = await axios . post ( '/api/v1/user/signup' )
36+ expect ( response . status ) . toBe ( 200 )
37+ } ) ;
38+
39+
40+
41+
42+
43+ // beforeAll(async () => {
44+ // await db.migrate.rollback()
45+ // await db.migrate.latest()
46+ // });
47+
48+ // it('signs up a user', async () => {
49+ // expect.assertions(1)
50+ // const response = await request.post('/api/v1/user/signup', {
51+ // "firstName": "TestFirstName",
52+ // "lastName": "TestLastName",
53+ // "username": "TestUsername",
54+ // "email": "TestEmail@example.com",
55+ // "password": "TestPassword"
56+ // })
57+ // expect(response.status).toBe(200)
58+ // });
59+
60+ // it('authenticates a user', async () => {
61+ // expect.assertions(1)
62+ // const response = await request.post('/api/v1/user/authenticate', {
63+ // "username": "TestUsername",
64+ // "password": "TestPassword"
65+ // })
66+ // expect(response.status).toBe(200)
67+ // });
68+ } )
0 commit comments