synapse-admin/tests/features/examples/RedditListPage.test.js
Manuel Stahl 00d6959927 Create synapse-admin using 'rekit create --sass synapse-admin'
Change-Id: I14a94754264c83faffb7fea5099d37c97e60b07a
2019-03-11 17:06:04 +01:00

52 lines
1.6 KiB
JavaScript

import React from 'react';
import { shallow } from 'enzyme';
import { RedditListPage } from '../../../src/features/examples/RedditListPage';
describe('examples/RedditListPage', () => {
it('renders node with correct class name', () => {
const props = {
examples: { redditList: [] },
actions: {},
};
const renderedComponent = shallow(<RedditListPage {...props} />);
expect(renderedComponent.find('.examples-reddit-list-page').length).toBe(1);
expect(renderedComponent.find('.no-items-tip').length).toBe(1);
});
it("renders list items when there's data", () => {
const props = {
examples: { redditList: [{ data: { id: 'id', title: 'title', url: 'url' } }] },
actions: {},
};
const renderedComponent = shallow(<RedditListPage {...props} />);
expect(renderedComponent.find('.examples-reddit-list-page').length).toBe(1);
});
it('should disable fetch button when fetching reddit', () => {
const pageProps = {
examples: {
redditList: [],
fetchRedditListPending: true,
},
actions: {},
};
const renderedComponent = shallow(<RedditListPage {...pageProps} />);
expect(renderedComponent.find('.btn-fetch-reddit[disabled]').length).toBe(1);
});
it('should show error if fetch failed', () => {
const pageProps = {
examples: {
redditList: [],
fetchRedditListError: new Error('server error'),
},
actions: {},
};
const renderedComponent = shallow(<RedditListPage {...pageProps} />);
expect(renderedComponent.find('.fetch-list-error').length).toBe(1);
});
});