Skip to content

Commit

Permalink
re-render in GitPanel unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Zsailer committed May 15, 2024
1 parent 65598ca commit 02a8f59
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/__tests__/test-components/GitPanel.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as apputils from '@jupyterlab/apputils';
import { nullTranslator } from '@jupyterlab/translation';
import { JSONObject } from '@lumino/coreutils';
import '@testing-library/jest-dom';
import { render, screen, waitFor } from '@testing-library/react';
import { RenderResult, render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import 'jest';
import React from 'react';
Expand Down Expand Up @@ -108,6 +108,7 @@ describe('GitPanel', () => {
describe('#commitFiles()', () => {
let commitSpy: jest.SpyInstance<Promise<void>>;
let configSpy: jest.SpyInstance<Promise<void | JSONObject>>;
let renderResult: RenderResult;

const commitSummary = 'Fix really stupid bug';
const commitDescription = 'This will probably break everything :)';
Expand Down Expand Up @@ -181,7 +182,7 @@ describe('GitPanel', () => {
props.model['_statusChanged'].emit(props.model['_status']);
});

render(<GitPanel {...props} />);
renderResult = render(<GitPanel {...props} />);
});

it('should commit when commit message is provided', async () => {
Expand Down Expand Up @@ -223,6 +224,9 @@ describe('GitPanel', () => {
it('should prompt for user identity if explicitly configured', async () => {
configSpy.mockResolvedValue({ options: commitUser });

props.settings = MockSettings(false, true) as any;
renderResult.rerender(<GitPanel {...props} />);

mockUtils.showDialog.mockResolvedValue(dialogValue);

await userEvent.type(screen.getAllByRole('textbox')[0], commitSummary);
Expand Down

0 comments on commit 02a8f59

Please sign in to comment.