@@ -104,6 +104,47 @@ module.exports = () => {
104104 } ) ;
105105 } ) ;
106106
107+ // test
108+ tap . test ( 'Should deploy without auth but with token' , t => {
109+ // spy on console
110+ const consoleSpy = sinon . spy ( console , 'log' ) ;
111+ // copy original config for restoration
112+ const originalConfig = Object . assign ( { } , userConfig ) ;
113+
114+ // handle correct request
115+ const deployServer = nock ( 'http://localhost:8080' ) . post ( '/deploy' ) . reply ( ( uri , requestBody , cb ) => {
116+ cb ( null , [ 200 , { status : 'success' , deployments} ] ) ;
117+ } ) ;
118+
119+ // remove auth from config
120+ updateConfig ( { endpoint : 'http://localhost:8080' } ) ;
121+
122+ // execute login
123+ deploy ( { token : 'test-token' } ) . then ( ( ) => {
124+ // make sure log in was successful
125+ // check that server was called
126+ t . ok ( deployServer . isDone ( ) ) ;
127+ // first check console output
128+ t . deepEqual (
129+ consoleSpy . args ,
130+ [
131+ [ 'Deploying current project to endpoint:' , 'http://localhost:8080' ] ,
132+ [ 'Deploying using given token..' ] ,
133+ [ 'Your project is now deployed as:\n' ] ,
134+ [ ' ID URL Hostname \n test http://localhost test ' ] ,
135+ ] ,
136+ 'Correct log output'
137+ ) ;
138+ // restore console
139+ console . log . restore ( ) ;
140+ // tear down nock
141+ deployServer . done ( ) ;
142+ // restore original config
143+ updateConfig ( originalConfig ) ;
144+ t . end ( ) ;
145+ } ) ;
146+ } ) ;
147+
107148 // test
108149 tap . test ( 'Should not deploy with broken config' , t => {
109150 // spy on console
0 commit comments