@@ -2,7 +2,7 @@ import * as apputils from '@jupyterlab/apputils';
22import { nullTranslator } from '@jupyterlab/translation' ;
33import { JSONObject } from '@lumino/coreutils' ;
44import '@testing-library/jest-dom' ;
5- import { render , screen , waitFor } from '@testing-library/react' ;
5+ import { RenderResult , render , screen , waitFor } from '@testing-library/react' ;
66import userEvent from '@testing-library/user-event' ;
77import 'jest' ;
88import React from 'react' ;
@@ -41,15 +41,20 @@ const mockedResponses: {
4141 * @private
4242 * @returns mock settings
4343 */
44- function MockSettings ( commitAndPush = true , promptUserIdentity = false ) {
44+ function MockSettings (
45+ commitAndPush = true ,
46+ promptUserIdentity = false ,
47+ simpleStaging = false
48+ ) {
4549 return {
4650 changed : {
4751 connect : ( ) => true ,
4852 disconnect : ( ) => true
4953 } ,
5054 composite : {
5155 commitAndPush,
52- promptUserIdentity
56+ promptUserIdentity,
57+ simpleStaging
5358 }
5459 } ;
5560}
@@ -103,6 +108,7 @@ describe('GitPanel', () => {
103108 describe ( '#commitFiles()' , ( ) => {
104109 let commitSpy : jest . SpyInstance < Promise < void > > ;
105110 let configSpy : jest . SpyInstance < Promise < void | JSONObject > > ;
111+ let renderResult : RenderResult ;
106112
107113 const commitSummary = 'Fix really stupid bug' ;
108114 const commitDescription = 'This will probably break everything :)' ;
@@ -151,8 +157,6 @@ describe('GitPanel', () => {
151157 beforeEach ( ( ) => {
152158 configSpy = props . model . config = jest . fn ( ) ;
153159 commitSpy = props . model . commit = jest . fn ( ) ;
154- // @ts -expect-error turn off set status
155- props . model . _setStatus = jest . fn ( ) ;
156160
157161 // @ts -expect-error set a private prop
158162 props . model . _status = {
@@ -173,10 +177,15 @@ describe('GitPanel', () => {
173177 state : 0
174178 } ;
175179
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 } /> ) ;
177186 } ) ;
178187
179- it . skip ( 'should commit when commit message is provided' , async ( ) => {
188+ it ( 'should commit when commit message is provided' , async ( ) => {
180189 configSpy . mockResolvedValue ( { options : commitUser } ) ;
181190
182191 await userEvent . type ( screen . getAllByRole ( 'textbox' ) [ 0 ] , commitSummary ) ;
@@ -212,16 +221,18 @@ describe('GitPanel', () => {
212221 expect ( commitSpy ) . not . toHaveBeenCalled ( ) ;
213222 } ) ;
214223
215- it . skip ( 'should prompt for user identity if explicitly configured' , async ( ) => {
224+ it ( 'should prompt for user identity if explicitly configured' , async ( ) => {
216225 configSpy . mockResolvedValue ( { options : commitUser } ) ;
217226
218227 props . settings = MockSettings ( false , true ) as any ;
219- render ( < GitPanel { ...props } /> ) ;
228+ renderResult . rerender ( < GitPanel { ...props } /> ) ;
220229
221230 mockUtils . showDialog . mockResolvedValue ( dialogValue ) ;
222231
223232 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+ ) ;
225236
226237 expect ( configSpy ) . toHaveBeenCalledTimes ( 1 ) ;
227238 expect ( configSpy . mock . calls [ 0 ] ) . toHaveLength ( 0 ) ;
@@ -231,7 +242,7 @@ describe('GitPanel', () => {
231242 expect ( commitSpy ) . toHaveBeenCalledWith ( commitSummary , false , author ) ;
232243 } ) ;
233244
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 ( ) => {
235246 configSpy . mockImplementation ( mockConfigImplementation ( 'user.email' ) ) ;
236247 mockUtils . showDialog . mockResolvedValue ( dialogValue ) ;
237248
@@ -247,7 +258,7 @@ describe('GitPanel', () => {
247258 expect ( commitSpy ) . toHaveBeenCalledWith ( commitSummary , false , null ) ;
248259 } ) ;
249260
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 ( ) => {
251262 configSpy . mockImplementation ( mockConfigImplementation ( 'user.name' ) ) ;
252263 mockUtils . showDialog . mockResolvedValue ( dialogValue ) ;
253264
@@ -263,7 +274,7 @@ describe('GitPanel', () => {
263274 expect ( commitSpy ) . toHaveBeenCalledWith ( commitSummary , false , null ) ;
264275 } ) ;
265276
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 ( ) => {
267278 configSpy . mockResolvedValue ( { options : { } } ) ;
268279 mockUtils . showDialog . mockResolvedValue ( {
269280 button : {
0 commit comments