mirror of
https://github.com/apache/superset.git
synced 2026-04-11 12:26:05 +00:00
* [toasts] get rid of notify globals, refactor messageToasts for use by entire app * [remove notify] use arrow func in ajax call * fix lint + tests * actually fix tests from messageToast refactor * add 'test:one' npm script * debugger * [toasts] convert bootstrap flash messages to toasts in explore + sqllab * [toasts][tests] import from right file
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
import { Alert } from 'react-bootstrap';
|
|
import React from 'react';
|
|
import { shallow } from 'enzyme';
|
|
import { describe, it } from 'mocha';
|
|
import { expect } from 'chai';
|
|
|
|
import mockMessageToasts from '../mockMessageToasts';
|
|
import Toast from '../../../../src/messageToasts/components/Toast';
|
|
|
|
describe('Toast', () => {
|
|
const props = {
|
|
toast: mockMessageToasts[0],
|
|
onCloseToast() {},
|
|
};
|
|
|
|
function setup(overrideProps) {
|
|
const wrapper = shallow(<Toast {...props} {...overrideProps} />);
|
|
return wrapper;
|
|
}
|
|
|
|
it('should render an Alert', () => {
|
|
const wrapper = setup();
|
|
expect(wrapper.find(Alert)).to.have.length(1);
|
|
});
|
|
|
|
it('should render toastText within the alert', () => {
|
|
const wrapper = setup();
|
|
const alert = wrapper.find(Alert).dive();
|
|
|
|
expect(alert.childAt(1).text()).to.equal(props.toast.text);
|
|
});
|
|
|
|
it('should call onCloseToast upon alert dismissal', done => {
|
|
const onCloseToast = id => {
|
|
expect(id).to.equal(props.toast.id);
|
|
done();
|
|
};
|
|
const wrapper = setup({ onCloseToast });
|
|
const handleClosePress = wrapper.instance().handleClosePress;
|
|
expect(wrapper.find(Alert).prop('onDismiss')).to.equal(handleClosePress);
|
|
handleClosePress(); // there is a timeout for onCloseToast to be called
|
|
});
|
|
});
|