Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: catch the throw error message from the luis file check function #2557

Merged
merged 7 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import * as React from 'react';
import { render, fireEvent } from 'react-testing-library';

import { EmulatorOpenButton } from '../../../src/components/TestController/emulatorOpenButton';
import { BotStatus } from '../../../src/constants/index';

describe('<EmulatorOpenButton />', () => {
it('should show the button to open emulator', () => {
const onClick = jest.fn(() => {});
const { container, getByText } = render(
<EmulatorOpenButton onClick={onClick} botStatus={BotStatus.connected} hidden={false} />
);

expect(container).toHaveTextContent('Test in Emulator');

const button = getByText('Test in Emulator');
fireEvent.click(button);
expect(onClick).toBeCalledTimes(1);
});

it('should hidden the button if set hidden', () => {
const onClick = jest.fn(() => {});
const { container } = render(
<EmulatorOpenButton onClick={onClick} botStatus={BotStatus.connected} hidden={true} />
);

expect(container).not.toHaveTextContent('Test in Emulator');
});

it('should show the button if the bot status is not connected', () => {
const onClick = jest.fn(() => {});
const { container } = render(
<EmulatorOpenButton onClick={onClick} botStatus={BotStatus.publishing} hidden={false} />
);

expect(container).not.toHaveTextContent('Test in Emulator');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import * as React from 'react';
import { render, fireEvent, getByText } from 'react-testing-library';

import { ErrorCallout } from '../../../src/components/TestController/errorCallout';

describe('<ErrorCallout />', () => {
it('should render the <ErrorCallout />', () => {
const onDismiss = jest.fn(() => {});
const onTry = jest.fn(() => {});

render(
<ErrorCallout
onDismiss={onDismiss}
onTry={onTry}
target={null}
visible={true}
error={{ title: 'title test', message: 'message test' }}
/>
);

const container = document.querySelector('[role="alertdialog"]');
expect(container).toHaveTextContent('title test');

const tryButton = getByText(container as HTMLElement, 'Try again');
const cancelButton = getByText(container as HTMLElement, 'Cancel');
fireEvent.click(tryButton);
fireEvent.click(cancelButton);
expect(onTry).toBeCalledTimes(1);
expect(onDismiss).toBeCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import * as React from 'react';
import { render, fireEvent } from 'react-testing-library';

import { ErrorInfo } from '../../../src/components/TestController/errorInfo';

describe('<ErrorInfo />', () => {
it('should render <ErrorInfo />', () => {
const onClick = jest.fn(() => {});
const { container, getByText } = render(<ErrorInfo onClick={onClick} count={5} hidden={false} />);

expect(container).toHaveTextContent('5');

const button = getByText('5');
fireEvent.click(button);
expect(onClick).toBeCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import * as React from 'react';
import { render } from 'react-testing-library';

import { Loading } from '../../../src/components/TestController/loading';
import { BotStatus } from '../../../src/constants';

describe('<Loading />', () => {
it('should render <Loading />', () => {
const { container, rerender } = render(<Loading botStatus={BotStatus.publishing} />);

expect(container).toHaveTextContent('Publishing');

rerender(<Loading botStatus={BotStatus.connected} />);

expect(container).not.toHaveTextContent('Publishing');
expect(container).not.toHaveTextContent('Reloading');
});
});
248 changes: 0 additions & 248 deletions Composer/packages/client/src/TestController.tsx

This file was deleted.

Loading