get rid of global notify (#5355)

* [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
This commit is contained in:
Chris Williams
2018-07-12 11:50:25 -07:00
committed by GitHub
parent f9352af80e
commit 19ac6e1231
72 changed files with 657 additions and 524 deletions

View File

@@ -0,0 +1,41 @@
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';
import ToastPresenter from '../../../../src/messageToasts/components/ToastPresenter';
describe('ToastPresenter', () => {
const props = {
toasts: mockMessageToasts,
removeToast() {},
};
function setup(overrideProps) {
const wrapper = shallow(<ToastPresenter {...props} {...overrideProps} />);
return wrapper;
}
it('should render a div with class toast-presenter', () => {
const wrapper = setup();
expect(wrapper.find('.toast-presenter')).to.have.length(1);
});
it('should render a Toast for each toast object', () => {
const wrapper = setup();
expect(wrapper.find(Toast)).to.have.length(props.toasts.length);
});
it('should pass removeToast to the Toast component', () => {
const removeToast = () => {};
const wrapper = setup({ removeToast });
expect(
wrapper
.find(Toast)
.first()
.prop('onCloseToast'),
).to.equal(removeToast);
});
});