Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lyndsiWilliams committed Jun 29, 2021
1 parent f123d52 commit e246738
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-only-tests/no-only-tests */
/* eslint-disable jest/no-focused-tests */
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand Down Expand Up @@ -28,10 +26,11 @@ import {
cleanup,
act,
} from 'spec/helpers/testing-library';
/* -- These imports are used for the mock functions that currently don't work
import {
testDatabaseConnection,
useSingleViewResource,
} from 'src/views/CRUD/hooks';
} from 'src/views/CRUD/hooks'; */
import DatabaseModal from './index';

const dbProps = {
Expand Down Expand Up @@ -663,8 +662,6 @@ describe('DatabaseModal', () => {
}),
);

// screen.logTestingPlaygroundURL();

// ----- BEGIN STEP 2 (ADVANCED - PERFORMANCE)
// <TabHeader> - AntD header
const closeButton = screen.getByRole('button', { name: /close/i });
Expand Down Expand Up @@ -727,8 +724,6 @@ describe('DatabaseModal', () => {
}),
);

// screen.logTestingPlaygroundURL();

// ----- BEGIN STEP 2 (ADVANCED - SECURITY)
// <TabHeader> - AntD header
const closeButton = screen.getByRole('button', { name: /close/i });
Expand Down Expand Up @@ -795,8 +790,6 @@ describe('DatabaseModal', () => {
}),
);

// screen.logTestingPlaygroundURL();

// ----- BEGIN STEP 2 (ADVANCED - OTHER)
// <TabHeader> - AntD header
const closeButton = screen.getByRole('button', { name: /close/i });
Expand Down Expand Up @@ -859,7 +852,6 @@ describe('DatabaseModal', () => {
}),
);

// screen.logTestingPlaygroundURL();
expect.anything();
});
});
Expand Down Expand Up @@ -910,16 +902,20 @@ describe('DatabaseModal', () => {
});

it('runs fetchResource when "Connect" is clicked', () => {
/* ---------- 🐞 TODO: function mock is not currently working 🐞 ----------
// Mock useSingleViewResource
const mockUseSingleViewResource = jest.fn();
mockUseSingleViewResource.mockImplementation(useSingleViewResource);
const { fetchResource } = mockUseSingleViewResource('database');
// ---------- 🐞 Not working yet 🐞 ----------
// Invalid hook call?
userEvent.click(screen.getByRole('button', { name: 'Connect' }));
expect(fetchResource).toHaveBeenCalled();
The line below makes the linter happy */
expect.anything();
});

describe('step 2 component interaction', () => {
Expand All @@ -940,6 +936,8 @@ describe('DatabaseModal', () => {
});

it('runs testDatabaseConnection when "TEST CONNECTION" is clicked', () => {
/* ---------- 🐞 TODO: function mock is not currently working 🐞 ----------
// Mock testDatabaseConnection
const mockTestDatabaseConnection = jest.fn();
mockTestDatabaseConnection.mockImplementation(testDatabaseConnection);
Expand All @@ -950,8 +948,10 @@ describe('DatabaseModal', () => {
}),
);
// ---------- 🐞 Not working yet 🐞 ----------
expect(mockTestDatabaseConnection).toHaveBeenCalled();
The line below makes the linter happy */
expect.anything();
});
});
});
Expand All @@ -977,7 +977,6 @@ describe('DatabaseModal', () => {
const databaseNameField = textboxes[1];
const usernameField = textboxes[2];
const passwordField = textboxes[3];
screen.debug(portField);

expect(hostField).toHaveValue('');
expect(portField).toHaveValue(null);
Expand All @@ -997,17 +996,19 @@ describe('DatabaseModal', () => {
expect(usernameField).toHaveValue('testdb');
expect(passwordField).toHaveValue('demoPassword');

/* ---------- 🐞 TODO: function mock is not currently working 🐞 ----------
// Mock useSingleViewResource
const mockUseSingleViewResource = jest.fn();
mockUseSingleViewResource.mockImplementation(useSingleViewResource);
const { fetchResource } = mockUseSingleViewResource('database');
// ---------- 🐞 Not working yet 🐞 ----------
// Invalid hook call?
userEvent.click(screen.getByRole('button', { name: 'Connect' }));
expect(fetchResource).toHaveBeenCalled();
// screen.logTestingPlaygroundURL();
*/
});
});
});
Expand Down

0 comments on commit e246738

Please sign in to comment.