Skip to content

Commit

Permalink
Adds many more tests, cleans-up PipelineSelector a bit, and fixes bug…
Browse files Browse the repository at this point in the history
… in Utils.ts
  • Loading branch information
rileyjbauer committed Nov 13, 2018
1 parent 6268f20 commit f56e4ab
Show file tree
Hide file tree
Showing 6 changed files with 1,350 additions and 4,289 deletions.
6 changes: 3 additions & 3 deletions frontend/src/components/UploadPipelineDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ describe('UploadPipelineDialog', () => {
it('calls close callback with null and empty string when canceled', () => {
const spy = jest.fn();
const tree = shallow(<UploadPipelineDialog open={false} onClose={spy} />);
tree.find('#cancelUploadBtn').at(0).simulate('click');
tree.find('#cancelUploadBtn').simulate('click');
expect(spy).toHaveBeenCalledWith('', null, '');
});

it('calls close callback with null and empty string when dialog is closed', () => {
const spy = jest.fn();
const tree = shallow(<UploadPipelineDialog open={false} onClose={spy} />);
tree.find('WithStyles(Dialog)').at(0).simulate('close');
tree.find('WithStyles(Dialog)').simulate('close');
expect(spy).toHaveBeenCalledWith('', null, '');
});

Expand All @@ -60,7 +60,7 @@ describe('UploadPipelineDialog', () => {
const tree = shallow(<UploadPipelineDialog open={false} onClose={spy} />);
(tree.instance() as any)._dropzoneRef = { current: { open: () => null } };
(tree.instance() as UploadPipelineDialog).handleChange('uploadPipelineName')({ target: { value: 'test name' } });
tree.find('#confirmUploadBtn').at(0).simulate('click');
tree.find('#confirmUploadBtn').simulate('click');
expect(spy).toHaveBeenLastCalledWith('test name', null, '');
});

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lib/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function formatDateString(date: Date | string | undefined): string {
}
}

// TODO: add tests
export async function errorToMessage(error: any): Promise<string> {
if (error instanceof Error) {
return error.message;
Expand All @@ -46,7 +47,7 @@ export async function errorToMessage(error: any): Promise<string> {
return await error.text();
}

return JSON.stringify(error || '');
return JSON.stringify(error) || '';
}

export function enabledDisplayString(trigger: ApiTrigger | undefined, enabled: boolean): string {
Expand Down
Loading

0 comments on commit f56e4ab

Please sign in to comment.