Skip to content

Commit

Permalink
Fixes test suite warnings
Browse files Browse the repository at this point in the history
Fixes the test suite warnings that are unrelated to the class -> functional conversion
  • Loading branch information
khanniie committed Aug 16, 2024
1 parent 272645f commit a39cac7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import EditorAccessibility from './EditorAccessibility';

describe('<EditorAccessibility />', () => {
it('renders empty message with no lines', () => {
render(<EditorAccessibility lintMessages={[]} />);
render(<EditorAccessibility lintMessages={[]} currentLine={0}/>);

Check failure on line 9 in client/modules/IDE/components/EditorAccessibility.unit.test.jsx

View workflow job for this annotation

GitHub Actions / Test and lint code base

Insert `·`

Check failure on line 9 in client/modules/IDE/components/EditorAccessibility.unit.test.jsx

View workflow job for this annotation

GitHub Actions / Test and lint code base

A space is required before closing bracket

expect(
screen.getByRole('listitem', {
Expand All @@ -21,11 +21,12 @@ describe('<EditorAccessibility />', () => {
lintMessages={[
{
severity: 'info',
line: '1',
line: 1,
message: 'foo',
id: '1a2b3c'
id: 123
}
]}
currentLine={0}
/>
);

Expand Down
6 changes: 3 additions & 3 deletions client/modules/IDE/components/ErrorModal.unit.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ jest.mock('../../../i18n');

describe('<ErrorModal />', () => {
it('renders type forceAuthentication', () => {
render(<ErrorModal type="forceAuthentication" closeModal={jest.fn()} />);
render(<ErrorModal type="forceAuthentication" closeModal={jest.fn()} service="google" />);

Check failure on line 11 in client/modules/IDE/components/ErrorModal.unit.test.jsx

View workflow job for this annotation

GitHub Actions / Test and lint code base

Replace `<ErrorModal·type="forceAuthentication"·closeModal={jest.fn()}·service="google"·/>` with `⏎······<ErrorModal⏎········type="forceAuthentication"⏎········closeModal={jest.fn()}⏎········service="google"⏎······/>⏎····`

expect(screen.getByText('Login')).toBeVisible();
expect(screen.getByText('Sign Up')).toBeVisible();
});

it('renders type staleSession', () => {
render(<ErrorModal type="staleSession" closeModal={jest.fn()} />);
render(<ErrorModal type="staleSession" closeModal={jest.fn()} service="google" />);

Check failure on line 18 in client/modules/IDE/components/ErrorModal.unit.test.jsx

View workflow job for this annotation

GitHub Actions / Test and lint code base

Replace `<ErrorModal·type="staleSession"·closeModal={jest.fn()}·service="google"·/>` with `⏎······<ErrorModal·type="staleSession"·closeModal={jest.fn()}·service="google"·/>⏎····`

expect(screen.getByText('log in')).toBeVisible();
});

it('renders type staleProject', () => {
render(<ErrorModal type="staleProject" closeModal={jest.fn()} />);
render(<ErrorModal type="staleProject" closeModal={jest.fn()} service="google" />);

Check failure on line 24 in client/modules/IDE/components/ErrorModal.unit.test.jsx

View workflow job for this annotation

GitHub Actions / Test and lint code base

Replace `<ErrorModal·type="staleProject"·closeModal={jest.fn()}·service="google"·/>` with `⏎······<ErrorModal·type="staleProject"·closeModal={jest.fn()}·service="google"·/>⏎····`

expect(
screen.getByText(
Expand Down
6 changes: 5 additions & 1 deletion client/modules/IDE/components/FileNode.unit.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,16 @@ describe('<FileNode />', () => {
});

it('can change to a different extension', async () => {
let mockConfirm = jest.fn(() => true);

Check failure on line 86 in client/modules/IDE/components/FileNode.unit.test.jsx

View workflow job for this annotation

GitHub Actions / Test and lint code base

'mockConfirm' is never reassigned. Use 'const' instead
window.confirm = mockConfirm;

Check failure on line 87 in client/modules/IDE/components/FileNode.unit.test.jsx

View workflow job for this annotation

GitHub Actions / Test and lint code base

Delete `··`

const newName = 'newname.gif';
const props = renderFileNode('file');

changeName(newName);

await waitFor(() => expect(props.updateFileName).not.toHaveBeenCalled());
expect(mockConfirm).toHaveBeenCalled();
await waitFor(() => expect(props.updateFileName).toHaveBeenCalledWith(props.id, newName));

Check failure on line 95 in client/modules/IDE/components/FileNode.unit.test.jsx

View workflow job for this annotation

GitHub Actions / Test and lint code base

Replace `·expect(props.updateFileName).toHaveBeenCalledWith(props.id,·newName)` with `⏎········expect(props.updateFileName).toHaveBeenCalledWith(props.id,·newName)⏎······`
await expectFileNameToBe(props.name);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ describe('project.controller', () => {
});

it('fails if user does not have permission', async () => {
// We don't want to clog up the jest output with extra
// logs, so we turn off console warn for this one test.
jest.spyOn(console, 'warn').mockImplementation(() => {});

request.user = { _id: 'abc123', username: 'alice' };
request.params = {
username: 'dana'
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/project.controller/createProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function apiCreateProject(req, res) {

const checkUserHasPermission = () => {
if (req.user.username !== req.params.username) {
console.log('no permission');
console.warn('no permission');
const error = new ProjectValidationError(
`'${req.user.username}' does not have permission to create for '${req.params.username}'`
);
Expand Down

0 comments on commit a39cac7

Please sign in to comment.