fix formatting
This commit is contained in:
@@ -3,9 +3,11 @@ import store from './store';
|
||||
describe('Store', () => {
|
||||
it('should trigger listener on add comment', () => {
|
||||
const listener = jest.fn();
|
||||
|
||||
store.set('comments', []);
|
||||
store.onUpdate('comments', listener);
|
||||
store.addComment({id:`new`});
|
||||
|
||||
expect(listener).toBeCalledWith([{"comment": {"id": "new"}}]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,46 +5,67 @@ import {createDomContainer} from 'testUtils';
|
||||
describe('<AuthPanel />', () => {
|
||||
describe('For not authorized user', () => {
|
||||
let container;
|
||||
|
||||
createDomContainer(({domContainer}) => {
|
||||
container = domContainer;
|
||||
});
|
||||
|
||||
it('should render login form with google and github provider', () => {
|
||||
const element = <AuthPanel user={{}} sort="-score" providers={[`google`, `github`]} />;
|
||||
|
||||
render(element, container);
|
||||
|
||||
const authPanelColumn = container.querySelectorAll('.auth-panel__column');
|
||||
|
||||
expect(authPanelColumn.length).toEqual(2);
|
||||
|
||||
const authForm = authPanelColumn[0];
|
||||
|
||||
expect(authForm.textContent)
|
||||
.toEqual(expect.stringContaining('Sign in to comment using'));
|
||||
|
||||
const providerLinks = authForm.querySelectorAll('.auth-panel__pseudo-link');
|
||||
|
||||
expect(providerLinks[0].textContent).toEqual('Google');
|
||||
expect(providerLinks[1].textContent).toEqual('GitHub');
|
||||
});
|
||||
});
|
||||
describe('For authorized user', () => {
|
||||
let container;
|
||||
|
||||
createDomContainer(({domContainer}) => {
|
||||
container = domContainer;
|
||||
});
|
||||
|
||||
it('should render info about current user', () => {
|
||||
const element = <AuthPanel user={{id: `test`, name: 'John'}} sort="-score" providers={[`google`, `github`]} />;
|
||||
|
||||
render(element, container);
|
||||
|
||||
const authPanelColumn = container.querySelectorAll('.auth-panel__column');
|
||||
|
||||
expect(authPanelColumn.length).toEqual(2);
|
||||
|
||||
const userInfo = authPanelColumn[0];
|
||||
|
||||
expect(userInfo.textContent)
|
||||
.toEqual(expect.stringContaining('You signed in as John. Sign out?'));
|
||||
});
|
||||
});
|
||||
describe('For admin user', () => {
|
||||
let container;
|
||||
|
||||
createDomContainer(({domContainer}) => {
|
||||
container = domContainer;
|
||||
});
|
||||
|
||||
it('should render admin action', () => {
|
||||
const element = <AuthPanel user={{id: `test`, admin: true, name: 'John'}} sort="-score" providers={[`google`, `github`]} />;
|
||||
|
||||
render(element, container);
|
||||
|
||||
const adminAction = container.querySelector('.auth-panel__admin-action');
|
||||
|
||||
expect(adminAction.textContent)
|
||||
.toEqual('Show blocked');
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ export default class AuthPanel extends Component {
|
||||
}
|
||||
|
||||
{
|
||||
loggedIn === false && (
|
||||
!loggedIn && (
|
||||
<div className="auth-panel__column">
|
||||
Sign in to comment using
|
||||
{' '}
|
||||
|
||||
@@ -4,12 +4,14 @@ import {createDomContainer} from 'testUtils';
|
||||
|
||||
describe(`<Preloader />`, () => {
|
||||
let container;
|
||||
|
||||
createDomContainer(({domContainer}) => {
|
||||
container = domContainer;
|
||||
});
|
||||
|
||||
it('should render Preloader', () => {
|
||||
render(<Preloader mix="root__preloader" />, container);
|
||||
|
||||
expect(container.children[0].className).toEqual('preloader root__preloader');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user