@@ -2,7 +2,7 @@ import * as apputils from '@jupyterlab/apputils';
2
2
import { nullTranslator } from '@jupyterlab/translation' ;
3
3
import { JSONObject } from '@lumino/coreutils' ;
4
4
import '@testing-library/jest-dom' ;
5
- import { render , screen , waitFor } from '@testing-library/react' ;
5
+ import { RenderResult , render , screen , waitFor } from '@testing-library/react' ;
6
6
import userEvent from '@testing-library/user-event' ;
7
7
import 'jest' ;
8
8
import React from 'react' ;
@@ -41,15 +41,20 @@ const mockedResponses: {
41
41
* @private
42
42
* @returns mock settings
43
43
*/
44
- function MockSettings ( commitAndPush = true , promptUserIdentity = false ) {
44
+ function MockSettings (
45
+ commitAndPush = true ,
46
+ promptUserIdentity = false ,
47
+ simpleStaging = false
48
+ ) {
45
49
return {
46
50
changed : {
47
51
connect : ( ) => true ,
48
52
disconnect : ( ) => true
49
53
} ,
50
54
composite : {
51
55
commitAndPush,
52
- promptUserIdentity
56
+ promptUserIdentity,
57
+ simpleStaging
53
58
}
54
59
} ;
55
60
}
@@ -103,6 +108,7 @@ describe('GitPanel', () => {
103
108
describe ( '#commitFiles()' , ( ) => {
104
109
let commitSpy : jest . SpyInstance < Promise < void > > ;
105
110
let configSpy : jest . SpyInstance < Promise < void | JSONObject > > ;
111
+ let renderResult : RenderResult ;
106
112
107
113
const commitSummary = 'Fix really stupid bug' ;
108
114
const commitDescription = 'This will probably break everything :)' ;
@@ -151,8 +157,6 @@ describe('GitPanel', () => {
151
157
beforeEach ( ( ) => {
152
158
configSpy = props . model . config = jest . fn ( ) ;
153
159
commitSpy = props . model . commit = jest . fn ( ) ;
154
- // @ts -expect-error turn off set status
155
- props . model . _setStatus = jest . fn ( ) ;
156
160
157
161
// @ts -expect-error set a private prop
158
162
props . model . _status = {
@@ -173,10 +177,15 @@ describe('GitPanel', () => {
173
177
state : 0
174
178
} ;
175
179
176
- render ( < GitPanel { ...props } /> ) ;
180
+ // @ts -expect-error turn off set status
181
+ props . model . _setStatus = jest . fn ( ( ) => {
182
+ props . model [ '_statusChanged' ] . emit ( props . model [ '_status' ] ) ;
183
+ } ) ;
184
+
185
+ renderResult = render ( < GitPanel { ...props } /> ) ;
177
186
} ) ;
178
187
179
- it . skip ( 'should commit when commit message is provided' , async ( ) => {
188
+ it ( 'should commit when commit message is provided' , async ( ) => {
180
189
configSpy . mockResolvedValue ( { options : commitUser } ) ;
181
190
182
191
await userEvent . type ( screen . getAllByRole ( 'textbox' ) [ 0 ] , commitSummary ) ;
@@ -212,16 +221,18 @@ describe('GitPanel', () => {
212
221
expect ( commitSpy ) . not . toHaveBeenCalled ( ) ;
213
222
} ) ;
214
223
215
- it . skip ( 'should prompt for user identity if explicitly configured' , async ( ) => {
224
+ it ( 'should prompt for user identity if explicitly configured' , async ( ) => {
216
225
configSpy . mockResolvedValue ( { options : commitUser } ) ;
217
226
218
227
props . settings = MockSettings ( false , true ) as any ;
219
- render ( < GitPanel { ...props } /> ) ;
228
+ renderResult . rerender ( < GitPanel { ...props } /> ) ;
220
229
221
230
mockUtils . showDialog . mockResolvedValue ( dialogValue ) ;
222
231
223
232
await userEvent . type ( screen . getAllByRole ( 'textbox' ) [ 0 ] , commitSummary ) ;
224
- await userEvent . click ( screen . getByRole ( 'button' , { name : 'Commit' } ) ) ;
233
+ await userEvent . click (
234
+ screen . getAllByRole ( 'button' , { name : 'Commit' } ) [ 0 ]
235
+ ) ;
225
236
226
237
expect ( configSpy ) . toHaveBeenCalledTimes ( 1 ) ;
227
238
expect ( configSpy . mock . calls [ 0 ] ) . toHaveLength ( 0 ) ;
@@ -231,7 +242,7 @@ describe('GitPanel', () => {
231
242
expect ( commitSpy ) . toHaveBeenCalledWith ( commitSummary , false , author ) ;
232
243
} ) ;
233
244
234
- it . skip ( 'should prompt for user identity if user.name is not set' , async ( ) => {
245
+ it ( 'should prompt for user identity if user.name is not set' , async ( ) => {
235
246
configSpy . mockImplementation ( mockConfigImplementation ( 'user.email' ) ) ;
236
247
mockUtils . showDialog . mockResolvedValue ( dialogValue ) ;
237
248
@@ -247,7 +258,7 @@ describe('GitPanel', () => {
247
258
expect ( commitSpy ) . toHaveBeenCalledWith ( commitSummary , false , null ) ;
248
259
} ) ;
249
260
250
- it . skip ( 'should prompt for user identity if user.email is not set' , async ( ) => {
261
+ it ( 'should prompt for user identity if user.email is not set' , async ( ) => {
251
262
configSpy . mockImplementation ( mockConfigImplementation ( 'user.name' ) ) ;
252
263
mockUtils . showDialog . mockResolvedValue ( dialogValue ) ;
253
264
@@ -263,7 +274,7 @@ describe('GitPanel', () => {
263
274
expect ( commitSpy ) . toHaveBeenCalledWith ( commitSummary , false , null ) ;
264
275
} ) ;
265
276
266
- it . skip ( 'should not commit if no user identity is set and the user rejects the dialog' , async ( ) => {
277
+ it ( 'should not commit if no user identity is set and the user rejects the dialog' , async ( ) => {
267
278
configSpy . mockResolvedValue ( { options : { } } ) ;
268
279
mockUtils . showDialog . mockResolvedValue ( {
269
280
button : {
0 commit comments