@@ -6,8 +6,8 @@ var helper = require('../generators/endpoint/promptingHelpers');
66var chalk = require ( 'chalk' ) ;
77
88describe ( 'generator-http-fake-backend → endpoint' , function ( ) {
9- before ( function ( done ) {
10- helpers . run ( path . join ( __dirname , '../generators/endpoint' ) )
9+ before ( function ( ) {
10+ return helpers . run ( path . join ( __dirname , '../generators/endpoint' ) )
1111 . withOptions ( { someOption : true } )
1212 . withPrompts ( {
1313 endpointName : 'endpoint' ,
@@ -17,7 +17,7 @@ describe('generator-http-fake-backend → endpoint', function () {
1717 response : '{ status: \'ok\' }' ,
1818 anotherUrl : false
1919 } )
20- . on ( 'end' , done ) ;
20+ . toPromise ( ) ;
2121 } ) ;
2222
2323 it ( 'should create endpoint.js' , function ( ) {
@@ -39,24 +39,27 @@ describe('generator-http-fake-backend → endpoint', function () {
3939 it ( 'should contain the prompted response' , function ( ) {
4040 assert . fileContent ( 'server/api/endpoint.js' , / r e s p o n s e : { s t a t u s : ' o k ' } / ) ;
4141 } ) ;
42+ it ( 'should not contain a statuscode key' , function ( ) {
43+ assert . noFileContent ( 'server/api/endpoint.js' , / s t a t u s C o d e / ) ;
44+ } ) ;
4245
4346 } ) ;
4447
4548} ) ;
4649
4750describe ( 'generator-http-fake-backend → endpoint → JSON file' , function ( ) {
48- before ( function ( done ) {
49- helpers . run ( path . join ( __dirname , '../generators/endpoint' ) )
51+ before ( function ( ) {
52+ return helpers . run ( path . join ( __dirname , '../generators/endpoint' ) )
5053 . withOptions ( { someOption : true } )
5154 . withPrompts ( {
5255 endpointName : 'endpoint' ,
53- params : '/bar' ,
5456 method : 'GET' ,
5557 responseType : 'json' ,
5658 response : 'foo.json' ,
59+ statusCode : 204 ,
5760 anotherUrl : false
5861 } )
59- . on ( 'end' , done ) ;
62+ . toPromise ( ) ;
6063 } ) ;
6164
6265 it ( 'should create foo.json' , function ( ) {
@@ -77,6 +80,14 @@ describe('generator-http-fake-backend → endpoint → JSON file', function () {
7780 assert . fileContent ( 'server/api/endpoint.js' , / r e s p o n s e : ' \/ j s o n - t e m p l a t e s \/ f o o .j s o n ' / ) ;
7881 } ) ;
7982
83+ it ( 'should contain the correct statuscode' , function ( ) {
84+ assert . fileContent ( 'server/api/endpoint.js' , / s t a t u s C o d e : 2 0 4 / ) ;
85+ } ) ;
86+
87+ it ( 'should not contain the params key' , function ( ) {
88+ assert . noFileContent ( 'server/api/endpoint.js' , / p a r a m s / ) ;
89+ } ) ;
90+
8091 } ) ;
8192
8293} ) ;
0 commit comments