Skip to content

Commit

Permalink
fix test for db modal
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh committed Jun 3, 2021
1 parent 145b947 commit cea7b6c
Showing 1 changed file with 0 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,72 +319,5 @@ describe('DatabaseModal', () => {
const todoText = screen.getAllByText(/todo/i);
expect(todoText[0]).toBeVisible();
});

describe('create database', () => {
it('should show a form when dynamic_form is selected', async () => {
const props = {
...dbProps,
databaseId: null,
database_name: null,
sqlalchemy_uri: null,
};
render(<DatabaseModal {...props} />, { useRedux: true });
// it should have the correct header text
const headerText = screen.getByText(/connect a database/i);
expect(headerText).toBeVisible();

await screen.findByText(/display name/i);

// it does not fetch any databases if no id is passed in
expect(fetchMock.calls().length).toEqual(0);

// todo we haven't hooked this up to load dynamically yet so
// we can't currently test it
});
});

describe('edit database', () => {
it('renders the sqlalchemy form when the sqlalchemy_form configuration method is set', async () => {
render(<DatabaseModal {...dbProps} />, { useRedux: true });

// it should have tabs
const tabs = screen.getAllByRole('tab');
expect(tabs.length).toEqual(2);
expect(tabs[0]).toHaveTextContent('Basic');
expect(tabs[1]).toHaveTextContent('Advanced');

// it should have the correct header text
const headerText = screen.getByText(/edit database/i);
expect(headerText).toBeVisible();

// todo add more when this form is built out
});
it('renders the dynamic form when the dynamic_form configuration method is set', async () => {
fetchMock.get(DATABASE_FETCH_ENDPOINT, {
result: {
id: 10,
database_name: 'my database',
expose_in_sqllab: false,
allow_ctas: false,
allow_cvas: false,
configuration_method: 'dynamic_form',
parameters: {
database: 'mydatabase',
},
},
});
render(<DatabaseModal {...dbProps} />, { useRedux: true });

await screen.findByText(/todo/i);

// // it should have tabs
const tabs = screen.getAllByRole('tab');
expect(tabs.length).toEqual(2);

// it should show a TODO for now
const todoText = screen.getAllByText(/todo/i);
expect(todoText[0]).toBeVisible();
});
});
});
});

0 comments on commit cea7b6c

Please sign in to comment.