docbrown/app/javascript/chat/__tests__/content.test.jsx
Rafi e3076a0852
[deploy] Removing hard-coded email (#10125)
* Removing hardcoded email

* Passing email address from siteConfig to react

* Passing modFaqEmail props in tests

* Changing webpacker compiler order
2020-10-20 18:59:51 +02:00

98 lines
2.6 KiB
JavaScript

import { h } from 'preact';
import { render } from '@testing-library/preact';
import { axe } from 'jest-axe';
import Content from '../content';
const getChannelRequestData = () => ({
onTriggerContent: jest.fn(),
type_of: 'channel-request',
activeChannelId: 12345,
pusherKey: 'ASDFGHJKL',
githubToken: '',
data: {
channel: {
name: 'bobby',
},
user: {
username: 'spongebob',
},
},
});
const getLoadingUserData = () => ({
onTriggerContent: jest.fn(),
type_of: 'loading-user',
activeChannelId: 1235,
pusherKey: 'ASDFGHJKL',
githubToken: '',
data: {
user: {
username: 'spongebob',
},
},
});
describe('<Content />', () => {
describe('as loading-user', () => {
it('should have no a11y violations', async () => {
const channelRequestResource = getChannelRequestData();
const { container } = render(
<Content
resource={channelRequestResource}
modFaqEmail="jane@doe.com"
/>,
);
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it('should render', () => {
const channelRequestResource = getChannelRequestData();
const { queryByText, queryByTitle } = render(
<Content
resource={channelRequestResource}
modFaqEmail="jane@doe.com"
/>,
);
// Ensure the two buttons render
expect(queryByTitle('exit')).toBeDefined();
expect(queryByTitle('fullscreen')).toBeDefined();
// Simple check if the component to request joining a channel appears.
// The component itself is tested it in it's own test suite.
expect(
queryByText(
'You are not a member of this group yet. Send a request to join.',
),
).toBeDefined();
});
});
describe('as channel-request', () => {
it('should have no a11y violations', async () => {
const loadinUserResource = getLoadingUserData();
const { container } = render(<Content resource={loadinUserResource} />);
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it('should render', () => {
const loadinUserResource = getLoadingUserData();
const { queryByTitle } = render(
<Content resource={loadinUserResource} />,
);
// Ensure the two buttons render
expect(queryByTitle('exit')).toBeDefined();
expect(queryByTitle('fullscreen')).toBeDefined();
expect(queryByTitle('Loading user')).toBeDefined();
});
});
/*
testing only as loading user since components that Content uses
are independently tested
*/
});