parent
1b2fcec0d7
commit
0a90c3c377
@ -0,0 +1,40 @@
|
||||
import { fromJS } from 'immutable';
|
||||
import React from 'react';
|
||||
|
||||
import { render, screen } from 'soapbox/jest/test-helpers';
|
||||
import { normalizeInstance } from 'soapbox/normalizers';
|
||||
|
||||
import Navbar from '../navbar';
|
||||
|
||||
describe('<Navbar />', () => {
|
||||
it('successfully renders', () => {
|
||||
render(<Navbar />);
|
||||
expect(screen.getByTestId('navbar')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('doesn\'t display the signup button by default', () => {
|
||||
render(<Navbar />);
|
||||
expect(screen.queryByText('Sign up')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe('with registrations enabled', () => {
|
||||
it('displays the signup button', () => {
|
||||
const store = { instance: normalizeInstance({ registrations: true }) };
|
||||
render(<Navbar />, undefined, store);
|
||||
expect(screen.getByText('Sign up')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('with registrations closed, Pepe enabled', () => {
|
||||
it('displays the signup button', () => {
|
||||
const store = {
|
||||
instance: normalizeInstance({ registrations: false }),
|
||||
soapbox: fromJS({ extensions: { pepe: { enabled: true } } }),
|
||||
verification: { instance: fromJS({ registrations: true }) },
|
||||
};
|
||||
|
||||
render(<Navbar />, undefined, store);
|
||||
expect(screen.getByText('Sign up')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,40 @@
|
||||
import { fromJS } from 'immutable';
|
||||
import React from 'react';
|
||||
|
||||
import { render, screen } from 'soapbox/jest/test-helpers';
|
||||
import { normalizeInstance } from 'soapbox/normalizers';
|
||||
|
||||
import LandingPageModal from '../landing-page-modal';
|
||||
|
||||
describe('<LandingPageModal />', () => {
|
||||
it('successfully renders', () => {
|
||||
render(<LandingPageModal onClose={jest.fn} />);
|
||||
expect(screen.getByTestId('modal')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('doesn\'t display the signup button by default', () => {
|
||||
render(<LandingPageModal onClose={jest.fn} />);
|
||||
expect(screen.queryByText('Register')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe('with registrations enabled', () => {
|
||||
it('displays the signup button', () => {
|
||||
const store = { instance: normalizeInstance({ registrations: true }) };
|
||||
render(<LandingPageModal onClose={jest.fn} />, undefined, store);
|
||||
expect(screen.getByText('Register')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('with registrations closed, Pepe enabled', () => {
|
||||
it('displays the signup button', () => {
|
||||
const store = {
|
||||
instance: normalizeInstance({ registrations: false }),
|
||||
soapbox: fromJS({ extensions: { pepe: { enabled: true } } }),
|
||||
verification: { instance: fromJS({ registrations: true }) },
|
||||
};
|
||||
|
||||
render(<LandingPageModal onClose={jest.fn} />, undefined, store);
|
||||
expect(screen.getByText('Register')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,40 @@
|
||||
import { fromJS } from 'immutable';
|
||||
import React from 'react';
|
||||
|
||||
import { render, screen } from 'soapbox/jest/test-helpers';
|
||||
import { normalizeInstance } from 'soapbox/normalizers';
|
||||
|
||||
import UnauthorizedModal from '../unauthorized-modal';
|
||||
|
||||
describe('<UnauthorizedModal />', () => {
|
||||
it('successfully renders', () => {
|
||||
render(<UnauthorizedModal onClose={jest.fn} action='FOLLOW' />);
|
||||
expect(screen.getByTestId('modal')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('doesn\'t display the signup button by default', () => {
|
||||
render(<UnauthorizedModal onClose={jest.fn} action='FOLLOW' />);
|
||||
expect(screen.queryByText('Sign up')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe('with registrations enabled', () => {
|
||||
it('displays the signup button', () => {
|
||||
const store = { instance: normalizeInstance({ registrations: true }) };
|
||||
render(<UnauthorizedModal onClose={jest.fn} action='FOLLOW' />, undefined, store);
|
||||
expect(screen.getByText('Sign up')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('with registrations closed, Pepe enabled', () => {
|
||||
it('displays the signup button', () => {
|
||||
const store = {
|
||||
instance: normalizeInstance({ registrations: false }),
|
||||
soapbox: fromJS({ extensions: { pepe: { enabled: true } } }),
|
||||
verification: { instance: fromJS({ registrations: true }) },
|
||||
};
|
||||
|
||||
render(<UnauthorizedModal onClose={jest.fn} action='FOLLOW' />, undefined, store);
|
||||
expect(screen.getByText('Sign up')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,35 @@
|
||||
import { fromJS } from 'immutable';
|
||||
import React from 'react';
|
||||
|
||||
import { render, screen } from 'soapbox/jest/test-helpers';
|
||||
import { normalizeInstance } from 'soapbox/normalizers';
|
||||
|
||||
import SignUpPanel from '../sign-up-panel';
|
||||
|
||||
describe('<SignUpPanel />', () => {
|
||||
it('doesn\'t render by default', () => {
|
||||
render(<SignUpPanel />);
|
||||
expect(screen.queryByTestId('sign-up-panel')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe('with registrations enabled', () => {
|
||||
it('successfully renders', () => {
|
||||
const store = { instance: normalizeInstance({ registrations: true }) };
|
||||
render(<SignUpPanel />, undefined, store);
|
||||
expect(screen.getByTestId('sign-up-panel')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('with registrations closed, Pepe enabled', () => {
|
||||
it('successfully renders', () => {
|
||||
const store = {
|
||||
instance: normalizeInstance({ registrations: false }),
|
||||
soapbox: fromJS({ extensions: { pepe: { enabled: true } } }),
|
||||
verification: { instance: fromJS({ registrations: true }) },
|
||||
};
|
||||
|
||||
render(<SignUpPanel />, undefined, store);
|
||||
expect(screen.getByTestId('sign-up-panel')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,62 @@
|
||||
import { fromJS } from 'immutable';
|
||||
|
||||
import { renderHook } from 'soapbox/jest/test-helpers';
|
||||
import { normalizeInstance } from 'soapbox/normalizers';
|
||||
|
||||
import { useRegistrationStatus } from '../useRegistrationStatus';
|
||||
|
||||
describe('useRegistrationStatus()', () => {
|
||||
test('Registrations open', () => {
|
||||
const store = { instance: normalizeInstance({ registrations: true }) };
|
||||
const { result } = renderHook(useRegistrationStatus, undefined, store);
|
||||
|
||||
expect(result.current).toMatchObject({
|
||||
isOpen: true,
|
||||
pepeEnabled: false,
|
||||
pepeOpen: false,
|
||||
});
|
||||
});
|
||||
|
||||
test('Registrations closed', () => {
|
||||
const store = { instance: normalizeInstance({ registrations: false }) };
|
||||
const { result } = renderHook(useRegistrationStatus, undefined, store);
|
||||
|
||||
expect(result.current).toMatchObject({
|
||||
isOpen: false,
|
||||
pepeEnabled: false,
|
||||
pepeOpen: false,
|
||||
});
|
||||
});
|
||||
|
||||
test('Registrations closed, Pepe enabled & open', () => {
|
||||
const store = {
|
||||
instance: normalizeInstance({ registrations: false }),
|
||||
soapbox: fromJS({ extensions: { pepe: { enabled: true } } }),
|
||||
verification: { instance: fromJS({ registrations: true }) },
|
||||
};
|
||||
|
||||
const { result } = renderHook(useRegistrationStatus, undefined, store);
|
||||
|
||||
expect(result.current).toMatchObject({
|
||||
isOpen: true,
|
||||
pepeEnabled: true,
|
||||
pepeOpen: true,
|
||||
});
|
||||
});
|
||||
|
||||
test('Registrations closed, Pepe enabled & closed', () => {
|
||||
const store = {
|
||||
instance: normalizeInstance({ registrations: false }),
|
||||
soapbox: fromJS({ extensions: { pepe: { enabled: true } } }),
|
||||
verification: { instance: fromJS({ registrations: false }) },
|
||||
};
|
||||
|
||||
const { result } = renderHook(useRegistrationStatus, undefined, store);
|
||||
|
||||
expect(result.current).toMatchObject({
|
||||
isOpen: false,
|
||||
pepeEnabled: true,
|
||||
pepeOpen: false,
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in new issue