@@ -11,7 +11,9 @@ module.exports = () => {
1111 // test update
1212 tap . test ( 'Should update traefik' , t => {
1313 // handle correct request
14- const updateServer = nock ( 'http://localhost:8080' ) . post ( '/update/traefik' ) . reply ( 200 , { updated : true } ) ;
14+ const updateServer = nock ( 'http://localhost:8080' )
15+ . post ( '/update/traefik' )
16+ . reply ( 200 , { updated : true } ) ;
1517 // spy on console
1618 const consoleSpy = sinon . spy ( console , 'log' ) ;
1719 // execute login
@@ -32,11 +34,39 @@ module.exports = () => {
3234 } ) ;
3335 } ) ;
3436
37+ // test update
38+ tap . test ( 'Should update server' , t => {
39+ // handle correct request
40+ const updateServer = nock ( 'http://localhost:8080' )
41+ . post ( '/update/server' )
42+ . reply ( 200 , { updated : true } ) ;
43+ // spy on console
44+ const consoleSpy = sinon . spy ( console , 'log' ) ;
45+ // execute login
46+ update ( { target : 'server' } ) . then ( ( ) => {
47+ // make sure log in was successful
48+ // check that server was called
49+ t . ok ( updateServer . isDone ( ) ) ;
50+ // first check console output
51+ t . deepEqual (
52+ consoleSpy . args ,
53+ [ [ 'Updating server on:' , 'http://localhost:8080' ] , [ 'Successfully updated server!' ] ] ,
54+ 'Correct log output'
55+ ) ;
56+ // restore console
57+ console . log . restore ( ) ;
58+ updateServer . done ( ) ;
59+ t . end ( ) ;
60+ } ) ;
61+ } ) ;
62+
3563 // test update error
3664 tap . test ( 'Should display update error' , t => {
3765 // handle correct request
3866 const response = { updated : false , error : 'Test error' , log : 'log' } ;
39- const updateServer = nock ( 'http://localhost:8080' ) . post ( '/update/traefik' ) . reply ( 500 , response ) ;
67+ const updateServer = nock ( 'http://localhost:8080' )
68+ . post ( '/update/traefik' )
69+ . reply ( 500 , response ) ;
4070 // spy on console
4171 const consoleSpy = sinon . spy ( console , 'log' ) ;
4272 // execute login
@@ -67,7 +97,9 @@ module.exports = () => {
6797 // copy original config for restoration
6898 const originalConfig = Object . assign ( { } , userConfig ) ;
6999 // handle correct request
70- const updateServer = nock ( 'http://localhost:8080' ) . post ( `/update/traefik` ) . reply ( 401 ) ;
100+ const updateServer = nock ( 'http://localhost:8080' )
101+ . post ( `/update/traefik` )
102+ . reply ( 401 ) ;
71103 // spy on console
72104 const consoleSpy = sinon . spy ( console , 'log' ) ;
73105 // execute login
0 commit comments