@@ -96,6 +96,24 @@ describe('netlify-cli', function() {
9696 assert . equal ( plugin . readConfig ( 'distDir' ) , 'my-dist-dir' ) ;
9797 } ) ;
9898
99+ it ( 'functionsDir' , function ( ) {
100+ const plugin = Plugin . createDeployPlugin ( { name : 'netlify-cli' } ) ;
101+
102+ plugin . beforeHook ( this . context ) ;
103+ plugin . configure ( this . context ) ;
104+
105+ assert . equal ( plugin . readConfig ( 'functionsDir' ) , '' ) ;
106+ } ) ;
107+
108+ it ( 'promoteToProd' , function ( ) {
109+ const plugin = Plugin . createDeployPlugin ( { name : 'netlify-cli' } ) ;
110+
111+ plugin . beforeHook ( this . context ) ;
112+ plugin . configure ( this . context ) ;
113+
114+ assert . equal ( plugin . readConfig ( 'promoteToProd' ) , true ) ;
115+ } ) ;
116+
99117 it ( 'revisionKey' , function ( ) {
100118 const plugin = Plugin . createDeployPlugin ( { name : 'netlify-cli' } ) ;
101119
@@ -121,5 +139,53 @@ describe('netlify-cli', function() {
121139 'NETLIFY_SITE_ID=my-project ' +
122140 'node_modules/.bin/netlify deploy --prod --dir my-dist-dir --message "v1.0.0+1234567"' ) ;
123141 } ) ;
142+
143+ it ( 'deploys to netlify with functions' , function ( ) {
144+ const plugin = Plugin . createDeployPlugin ( { name : 'netlify-cli' } ) ;
145+ const stub = this . sinon . stub ( plugin , '_exec' ) ;
146+ const context = {
147+ ...this . context ,
148+
149+ config : {
150+ 'netlify-cli' : {
151+ ...this . context . config [ 'netlify-cli' ] ,
152+ functionsDir : 'my-functions-dir'
153+ }
154+ }
155+ } ;
156+
157+ plugin . beforeHook ( context ) ;
158+ plugin . configure ( context ) ;
159+ plugin . upload ( ) ;
160+
161+ this . sinon . assert . calledWithExactly ( stub ,
162+ 'NETLIFY_AUTH_TOKEN=my-auth-token ' +
163+ 'NETLIFY_SITE_ID=my-project ' +
164+ 'node_modules/.bin/netlify deploy --prod --dir my-dist-dir --functions my-functions-dir --message "v1.0.0+1234567"' ) ;
165+ } ) ;
166+
167+ it ( 'deploys to netlify without promoting to prod' , function ( ) {
168+ const plugin = Plugin . createDeployPlugin ( { name : 'netlify-cli' } ) ;
169+ const stub = this . sinon . stub ( plugin , '_exec' ) ;
170+ const context = {
171+ ...this . context ,
172+
173+ config : {
174+ 'netlify-cli' : {
175+ ...this . context . config [ 'netlify-cli' ] ,
176+ promoteToProd : false
177+ }
178+ }
179+ } ;
180+
181+ plugin . beforeHook ( context ) ;
182+ plugin . configure ( context ) ;
183+ plugin . upload ( ) ;
184+
185+ this . sinon . assert . calledWithExactly ( stub ,
186+ 'NETLIFY_AUTH_TOKEN=my-auth-token ' +
187+ 'NETLIFY_SITE_ID=my-project ' +
188+ 'node_modules/.bin/netlify deploy --dir my-dist-dir --message "v1.0.0+1234567"' ) ;
189+ } ) ;
124190 } ) ;
125191} ) ;
0 commit comments