* adding more tests - covers article.jsx and elements created from its props and state - added png as static file that needs stubbing * video + channelDetails test coverage * chat + channels tests * channels cc refactor * yarn install * update snapshot and string spacing * chat.jsx test mostly tests rendering elements - does not test imported components, as those are already tested separately - does not imported functions from actions or utils as those will be tested separately as well * cleaning up - mocked response with flush promises for state/component to reflect appropriate changes * snapshot updates
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
import { h } from 'preact';
|
|
import render from 'preact-render-to-json';
|
|
import { shallow } from 'preact-render-spy';
|
|
import Alert from '../alert';
|
|
|
|
describe('<Alert />', () => {
|
|
describe('without hidden class', () => {
|
|
it('should render and test snapshot', () => {
|
|
const tree = render(<Alert showAlert />);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should have proper elements, attributes and values', () => {
|
|
const context = shallow(<Alert showAlert />);
|
|
expect(context.find('.chatalert__default').exists()).toEqual(true);
|
|
expect(context.find('.chatalert__default').text()).toEqual(
|
|
'More new messages below',
|
|
);
|
|
expect(context.find('.chatalert__default--hidden').exists()).toEqual(
|
|
false,
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('with hidden class', () => {
|
|
it('should render and test snapshot', () => {
|
|
const tree = render(<Alert showAlert={false} />);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should have proper elements, attributes and values', () => {
|
|
const context = shallow(<Alert showAlert={false} />);
|
|
expect(context.find('.chatalert__default').exists()).toEqual(true);
|
|
expect(context.find('.chatalert__default').text()).toEqual(
|
|
'More new messages below',
|
|
);
|
|
expect(context.find('.chatalert__default--hidden').exists()).toEqual(
|
|
true,
|
|
);
|
|
});
|
|
});
|
|
});
|