File tree Expand file tree Collapse file tree 5 files changed +9
-6
lines changed
Expand file tree Collapse file tree 5 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -9,9 +9,12 @@ class BaseApi {
99 this . baseUrl = 'http://localhost:3000' ;
1010 }
1111
12- // set get(url) {return this.request.get(url);};
13- setHeaders ( headers ) {
14- this . headers = headers ;
12+ /**
13+ * Add new headers to existing headers
14+ * @param {object } headers
15+ */
16+ setAdditionalHeaders ( headers ) {
17+ this . headers = Object . assign ( this . headers , headers ) ;
1518 this . request . set ( this . headers ) ;
1619 }
1720
Original file line number Diff line number Diff line change 11const request = require ( 'superagent' ) ;
22const baseUrl = global . baseUrl ;
33
4- describe ( 'Vegetables' , function ( ) {
4+ describe ( 'Vegetables baseline without framework ' , function ( ) {
55 it ( 'should get default' , async function ( ) {
66 const res = await request . get ( baseUrl + '/vegetables' ) ;
77 expect ( res . status ) . toBe ( 200 ) ;
Original file line number Diff line number Diff line change 11const BaseApi = require ( '../resources/BaseApi' ) ;
22const api = new BaseApi ( ) ;
33
4- describe ( 'Vegetables' , function ( ) {
4+ describe ( 'Vegetables - using baseApi ' , function ( ) {
55 it ( 'should get default' , async function ( ) {
66 const res = await api . get ( '/vegetables' ) ;
77 expect ( res . status ) . toBe ( 200 ) ;
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ async function main() {
88 // const res = await request.get(baseUrl + '/vegetables');
99 // const vegetables = res.body.map((vegetable) => new Vegetable(vegetable));
1010 // vegetables[0].getters;
11- baseApi . setHeaders ( { 'Content-type' : 'application/json' } ) ;
11+ baseApi . setAdditionalHeaders ( { 'Content-type' : 'application/json' } ) ;
1212 const res = await baseApi . get ( "/vegetables" , { } , { optional : 'false' } ) ;
1313 console . log ( res . status ) ;
1414 console . log ( res . body ) ;
You can’t perform that action at this time.
0 commit comments