@@ -108,14 +108,11 @@ describe('GitPanel', () => {
108
108
109
109
// Mock identity look up
110
110
const identity = jest
111
- . spyOn ( GitModel . prototype , 'config ' )
111
+ . spyOn ( GitModel . prototype , 'isCommitterIdentitySet ' )
112
112
. mockResolvedValue (
113
113
new Response (
114
114
JSON . stringify ( {
115
- options : {
116
- 'user.name' : 'John Snow' ,
117
-
118
- }
115
+ identityEstablished : true
119
116
} ) ,
120
117
{ status : 201 }
121
118
)
@@ -136,81 +133,29 @@ describe('GitPanel', () => {
136
133
spy . mockRestore ( ) ;
137
134
} ) ;
138
135
139
- it ( 'should prompt for user identity if user.name is not set' , async ( ) => {
136
+ it ( 'should prompt for user identity if not set' , async ( ) => {
140
137
const spy = jest . spyOn ( GitModel . prototype , 'commit' ) ;
141
138
142
- // Mock identity look up
143
- const identity = jest
139
+ const config = jest
144
140
. spyOn ( GitModel . prototype , 'config' )
145
141
. mockImplementation ( options => {
146
142
let response : Response = null ;
147
- if ( options === undefined ) {
148
- response = new Response (
149
- JSON . stringify ( {
150
- options : {
151
-
152
- }
153
- } ) ,
154
- { status : 201 }
155
- ) ;
156
- } else {
157
- response = new Response ( '' , { status : 201 } ) ;
158
- }
143
+ response = new Response ( '' , { status : 201 } ) ;
159
144
return Promise . resolve ( response ) ;
160
145
} ) ;
161
- const mock = apputils as jest . Mocked < typeof apputils > ;
162
- mock . showDialog . mockResolvedValue ( {
163
- button : {
164
- accept : true ,
165
- caption : '' ,
166
- className : '' ,
167
- displayType : 'default' ,
168
- iconClass : '' ,
169
- iconLabel : '' ,
170
- label : ''
171
- } ,
172
- value : {
173
- name : 'John Snow' ,
174
-
175
- }
176
- } ) ;
177
-
178
- const panel = new GitPanel ( props ) ;
179
- await panel . commitStagedFiles ( 'Initial commit' ) ;
180
- expect ( identity ) . toHaveBeenCalledTimes ( 2 ) ;
181
- expect ( identity . mock . calls [ 0 ] ) . toHaveLength ( 0 ) ;
182
- expect ( identity . mock . calls [ 1 ] ) . toEqual ( [
183
- {
184
- 'user.name' : 'John Snow' ,
185
-
186
- }
187
- ] ) ;
188
- expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
189
- expect ( spy ) . toHaveBeenCalledWith ( 'Initial commit' ) ;
190
- } ) ;
191
-
192
- it ( 'should prompt for user identity if user.email is not set' , async ( ) => {
193
- const spy = jest . spyOn ( GitModel . prototype , 'commit' ) ;
194
146
195
147
// Mock identity look up
196
148
const identity = jest
197
- . spyOn ( GitModel . prototype , 'config' )
198
- . mockImplementation ( options => {
199
- let response : Response = null ;
200
- if ( options === undefined ) {
201
- response = new Response (
202
- JSON . stringify ( {
203
- options : {
204
- 'user.name' : 'John Snow'
205
- }
206
- } ) ,
207
- { status : 201 }
208
- ) ;
209
- } else {
210
- response = new Response ( '' , { status : 201 } ) ;
211
- }
212
- return Promise . resolve ( response ) ;
213
- } ) ;
149
+ . spyOn ( GitModel . prototype , 'isCommitterIdentitySet' )
150
+ . mockResolvedValue (
151
+ new Response (
152
+ JSON . stringify ( {
153
+ identityEstablished : false
154
+ } ) ,
155
+ { status : 201 }
156
+ )
157
+ ) ;
158
+
214
159
const mock = apputils as jest . Mocked < typeof apputils > ;
215
160
mock . showDialog . mockResolvedValue ( {
216
161
button : {
@@ -230,9 +175,9 @@ describe('GitPanel', () => {
230
175
231
176
const panel = new GitPanel ( props ) ;
232
177
await panel . commitStagedFiles ( 'Initial commit' ) ;
233
- expect ( identity ) . toHaveBeenCalledTimes ( 2 ) ;
234
- expect ( identity . mock . calls [ 0 ] ) . toHaveLength ( 0 ) ;
235
- expect ( identity . mock . calls [ 1 ] ) . toEqual ( [
178
+ expect ( identity ) . toHaveBeenCalledTimes ( 1 ) ;
179
+ expect ( config ) . toHaveBeenCalledTimes ( 1 ) ;
180
+ expect ( config . mock . calls [ 0 ] ) . toEqual ( [
236
181
{
237
182
'user.name' : 'John Snow' ,
238
183
@@ -247,21 +192,16 @@ describe('GitPanel', () => {
247
192
248
193
// Mock identity look up
249
194
const identity = jest
250
- . spyOn ( GitModel . prototype , 'config' )
251
- . mockImplementation ( options => {
252
- let response : Response = null ;
253
- if ( options === undefined ) {
254
- response = new Response (
255
- JSON . stringify ( {
256
- options : { }
257
- } ) ,
258
- { status : 201 }
259
- ) ;
260
- } else {
261
- response = new Response ( '' , { status : 201 } ) ;
262
- }
263
- return Promise . resolve ( response ) ;
264
- } ) ;
195
+ . spyOn ( GitModel . prototype , 'isCommitterIdentitySet' )
196
+ . mockResolvedValue (
197
+ new Response (
198
+ JSON . stringify ( {
199
+ identityEstablished : false
200
+ } ) ,
201
+ { status : 201 }
202
+ )
203
+ ) ;
204
+
265
205
const mock = apputils as jest . Mocked < typeof apputils > ;
266
206
mock . showDialog . mockResolvedValue ( {
267
207
button : {
@@ -279,7 +219,6 @@ describe('GitPanel', () => {
279
219
const panel = new GitPanel ( props ) ;
280
220
await panel . commitStagedFiles ( 'Initial commit' ) ;
281
221
expect ( identity ) . toHaveBeenCalledTimes ( 1 ) ;
282
- expect ( identity ) . toHaveBeenCalledWith ( ) ;
283
222
expect ( spy ) . not . toHaveBeenCalled ( ) ;
284
223
} ) ;
285
224
} ) ;
0 commit comments