@@ -49,6 +49,12 @@ describe('CreateDialogController', function() {
49
49
50
50
buffer . setText ( 'home' ) ;
51
51
assert . strictEqual ( atomEnv . config . get ( 'github.sourceRemoteName' ) , 'home' ) ;
52
+
53
+ sinon . spy ( atomEnv . config , 'set' ) ;
54
+ buffer . setText ( 'home' ) ;
55
+ assert . isFalse ( atomEnv . config . set . called ) ;
56
+
57
+ wrapper . unmount ( ) ;
52
58
} ) ;
53
59
54
60
it ( 'synchronizes the source protocol from Atom configuration' , async function ( ) {
@@ -60,6 +66,16 @@ describe('CreateDialogController', function() {
60
66
61
67
await wrapper . find ( CreateDialogView ) . prop ( 'didChangeProtocol' ) ( 'https' ) ;
62
68
assert . strictEqual ( atomEnv . config . get ( 'github.remoteFetchProtocol' ) , 'https' ) ;
69
+
70
+ sinon . spy ( atomEnv . config , 'set' ) ;
71
+ await wrapper . find ( CreateDialogView ) . prop ( 'didChangeProtocol' ) ( 'https' ) ;
72
+ assert . isFalse ( atomEnv . config . set . called ) ;
73
+ } ) ;
74
+
75
+ it ( 'begins with an empty owner ID while loading' , function ( ) {
76
+ const wrapper = shallow ( buildApp ( { user : null , isLoading : true } ) ) ;
77
+
78
+ assert . strictEqual ( wrapper . find ( CreateDialogView ) . prop ( 'selectedOwnerID' ) , '' ) ;
63
79
} ) ;
64
80
65
81
it ( 'begins with the owner ID as the viewer ID' , function ( ) {
@@ -172,6 +188,12 @@ describe('CreateDialogController', function() {
172
188
173
189
assert . isFalse ( wrapper . find ( CreateDialogView ) . prop ( 'acceptEnabled' ) ) ;
174
190
} ) ;
191
+
192
+ it ( 'disables the accept button if user data has not loaded yet' , function ( ) {
193
+ const wrapper = shallow ( buildApp ( { user : null } ) ) ;
194
+
195
+ assert . isFalse ( wrapper . find ( CreateDialogView ) . prop ( 'acceptEnabled' ) ) ;
196
+ } ) ;
175
197
} ) ;
176
198
177
199
describe ( 'acceptance' , function ( ) {
@@ -187,6 +209,39 @@ describe('CreateDialogController', function() {
187
209
assert . isFalse ( accept . called ) ;
188
210
} ) ;
189
211
212
+ it ( 'uses the user ID if the selected owner ID was never changed' , async function ( ) {
213
+ const accept = sinon . spy ( ) ;
214
+ const request = dialogRequests . create ( ) ;
215
+ request . onAccept ( accept ) ;
216
+ const wrapper = shallow ( buildApp ( { request, user : null , isLoading : true } ) ) ;
217
+
218
+ assert . strictEqual ( wrapper . find ( CreateDialogView ) . prop ( 'selectedOwnerID' ) , '' ) ;
219
+
220
+ wrapper . setProps ( {
221
+ user : userBuilder ( userQuery ) . id ( 'my-id' ) . build ( ) ,
222
+ isLoading : false ,
223
+ } ) ;
224
+
225
+ wrapper . find ( CreateDialogView ) . prop ( 'repoName' ) . setText ( 'repo-name' ) ;
226
+ wrapper . find ( CreateDialogView ) . prop ( 'didChangeVisibility' ) ( 'PRIVATE' ) ;
227
+ wrapper . find ( CreateDialogView ) . prop ( 'localPath' ) . setText ( path . join ( '/local/path' ) ) ;
228
+ wrapper . find ( CreateDialogView ) . prop ( 'didChangeProtocol' ) ( 'ssh' ) ;
229
+ wrapper . find ( CreateDialogView ) . prop ( 'sourceRemoteName' ) . setText ( 'upstream' ) ;
230
+
231
+ assert . strictEqual ( wrapper . find ( CreateDialogView ) . prop ( 'selectedOwnerID' ) , '' ) ;
232
+
233
+ await wrapper . find ( CreateDialogView ) . prop ( 'accept' ) ( ) ;
234
+
235
+ assert . isTrue ( accept . calledWith ( {
236
+ ownerID : 'my-id' ,
237
+ name : 'repo-name' ,
238
+ visibility : 'PRIVATE' ,
239
+ localPath : path . join ( '/local/path' ) ,
240
+ protocol : 'ssh' ,
241
+ sourceRemoteName : 'upstream' ,
242
+ } ) ) ;
243
+ } ) ;
244
+
190
245
it ( 'resolves onAccept with the populated data' , async function ( ) {
191
246
const accept = sinon . spy ( ) ;
192
247
const request = dialogRequests . create ( ) ;
0 commit comments