style: new toast design closer to SIP-34 (#10178)

This commit is contained in:
Lily Kuang
2020-07-10 14:58:59 -07:00
committed by GitHub
parent 80b06f6827
commit 3b4df51848
13 changed files with 286 additions and 257 deletions

View File

@@ -34,9 +34,9 @@ describe('ToastPresenter', () => {
return wrapper;
}
it('should render a div with class toast-presenter', () => {
it('should render a div with id toast-presenter', () => {
const wrapper = setup();
expect(wrapper.find('.toast-presenter')).toHaveLength(1);
expect(wrapper.find('#toast-presenter')).toHaveLength(1);
});
it('should render a Toast for each toast object', () => {

View File

@@ -19,21 +19,19 @@
import { Alert } from 'react-bootstrap';
import React from 'react';
import { mount } from 'enzyme';
import { act } from 'react-dom/test-utils';
import Toast from 'src/messageToasts/components/Toast';
import mockMessageToasts from '../mockMessageToasts';
const props = {
toast: mockMessageToasts[0],
onCloseToast() {},
};
const setup = overrideProps => mount(<Toast {...props} {...overrideProps} />);
describe('Toast', () => {
const props = {
toast: mockMessageToasts[0],
onCloseToast() {},
};
function setup(overrideProps) {
const wrapper = mount(<Toast {...props} {...overrideProps} />);
return wrapper;
}
it('should render an Alert', () => {
const wrapper = setup();
expect(wrapper.find(Alert)).toHaveLength(1);
@@ -52,9 +50,13 @@ describe('Toast', () => {
expect(id).toBe(props.toast.id);
done();
};
const wrapper = setup({ onCloseToast });
const handleClosePress = wrapper.instance().handleClosePress;
expect(wrapper.find(Alert).prop('onDismiss')).toBe(handleClosePress);
const handleClosePress = wrapper.find('[label="Close alert"]').props()
.onClick;
const alertProps = wrapper.find(Alert).props();
expect(alertProps.onDismiss).toBe(handleClosePress);
handleClosePress(); // there is a timeout for onCloseToast to be called
});
});