@@ -108,14 +108,11 @@ describe('GitPanel', () => {
108108
109109 // Mock identity look up
110110 const identity = jest
111- . spyOn ( GitModel . prototype , 'config ' )
111+ . spyOn ( GitModel . prototype , 'isCommitterIdentitySet ' )
112112 . mockResolvedValue (
113113 new Response (
114114 JSON . stringify ( {
115- options : {
116- 'user.name' : 'John Snow' ,
117- 118- }
115+ identityEstablished : true
119116 } ) ,
120117 { status : 201 }
121118 )
@@ -136,81 +133,29 @@ describe('GitPanel', () => {
136133 spy . mockRestore ( ) ;
137134 } ) ;
138135
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 ( ) => {
140137 const spy = jest . spyOn ( GitModel . prototype , 'commit' ) ;
141138
142- // Mock identity look up
143- const identity = jest
139+ const config = jest
144140 . spyOn ( GitModel . prototype , 'config' )
145141 . mockImplementation ( options => {
146142 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 } ) ;
159144 return Promise . resolve ( response ) ;
160145 } ) ;
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' ) ;
194146
195147 // Mock identity look up
196148 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+
214159 const mock = apputils as jest . Mocked < typeof apputils > ;
215160 mock . showDialog . mockResolvedValue ( {
216161 button : {
@@ -230,9 +175,9 @@ describe('GitPanel', () => {
230175
231176 const panel = new GitPanel ( props ) ;
232177 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 ( [
236181 {
237182 'user.name' : 'John Snow' ,
238183@@ -247,21 +192,16 @@ describe('GitPanel', () => {
247192
248193 // Mock identity look up
249194 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+
265205 const mock = apputils as jest . Mocked < typeof apputils > ;
266206 mock . showDialog . mockResolvedValue ( {
267207 button : {
@@ -279,7 +219,6 @@ describe('GitPanel', () => {
279219 const panel = new GitPanel ( props ) ;
280220 await panel . commitStagedFiles ( 'Initial commit' ) ;
281221 expect ( identity ) . toHaveBeenCalledTimes ( 1 ) ;
282- expect ( identity ) . toHaveBeenCalledWith ( ) ;
283222 expect ( spy ) . not . toHaveBeenCalled ( ) ;
284223 } ) ;
285224 } ) ;
0 commit comments