11import { server } from '../app'
22import axios from 'axios'
3- // axios.defaults.baseURL = `http://localhost:4000`
43import MockAdapter from 'axios-mock-adapter' ;
5- // const baseUrl = `http://localhost:4000`
64const mock = new MockAdapter ( axios ) ;
75
6+ import UserActionController from '../src/controllers/UserActionController'
7+
88//After all the tests are done we're going to close our server
99//and rollback our database.
1010afterAll ( async ( ) => {
@@ -15,24 +15,27 @@ afterAll(async () => {
1515} ) ;
1616
1717describe ( 'user account actions' , ( ) => {
18+ const userActionController = new UserActionController ( )
1819
1920 it ( 'signs up a user' , async ( ) => {
2021 mock . onPost ( '/api/v1/user/signup' ) . reply ( function ( ) {
2122 return [ 200 , { foo : 'bar' } ] ;
2223 } ) ;
2324
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-
3425 expect . assertions ( 1 )
35- const response = await axios . post ( '/api/v1/user/signup' )
26+ //const response = await axios.post('/api/v1/user/signup')
27+ let ctx = {
28+ request : {
29+ body : {
30+ "firstName" : "John" ,
31+ "lastName" : "Datserakis" ,
32+ "username" : "johndatserakis@gmail.com" ,
33+ "email" : "johndatserakis@gmail.com" ,
34+ "password" : "Houses123993"
35+ }
36+ }
37+ }
38+ const response = await userActionController . signup ( ctx ) ;
3639 expect ( response . status ) . toBe ( 200 )
3740 } ) ;
3841
0 commit comments