2023-01-15 10:35:34 -08:00
|
|
|
import { fromJS } from 'immutable';
|
2022-05-10 03:17:01 -07:00
|
|
|
import React from 'react';
|
|
|
|
|
2023-01-11 17:01:45 -08:00
|
|
|
import { normalizeInstance } from 'soapbox/normalizers';
|
|
|
|
|
2022-05-10 03:17:01 -07:00
|
|
|
import { render, screen } from '../../../../jest/test-helpers';
|
|
|
|
import CtaBanner from '../cta-banner';
|
|
|
|
|
|
|
|
describe('<CtaBanner />', () => {
|
|
|
|
it('renders the banner', () => {
|
2023-01-11 17:38:05 -08:00
|
|
|
const store = { instance: normalizeInstance({ registrations: true }) };
|
|
|
|
|
|
|
|
render(<CtaBanner />, undefined, store);
|
2022-05-10 03:17:01 -07:00
|
|
|
expect(screen.getByTestId('cta-banner')).toHaveTextContent(/sign up/i);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with a logged in user', () => {
|
|
|
|
it('renders empty', () => {
|
|
|
|
const store = { me: true };
|
|
|
|
|
2022-07-06 10:16:14 -07:00
|
|
|
render(<CtaBanner />, undefined, store);
|
2022-05-10 03:17:01 -07:00
|
|
|
expect(screen.queryAllByTestId('cta-banner')).toHaveLength(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-01-11 17:01:45 -08:00
|
|
|
describe('with registrations closed', () => {
|
2022-05-10 03:17:01 -07:00
|
|
|
it('renders empty', () => {
|
2023-01-11 17:01:45 -08:00
|
|
|
const store = { instance: normalizeInstance({ registrations: false }) };
|
2022-05-10 03:17:01 -07:00
|
|
|
|
2022-07-06 10:16:14 -07:00
|
|
|
render(<CtaBanner />, undefined, store);
|
2022-05-10 03:17:01 -07:00
|
|
|
expect(screen.queryAllByTestId('cta-banner')).toHaveLength(0);
|
|
|
|
});
|
|
|
|
});
|
2023-01-15 10:35:34 -08:00
|
|
|
|
|
|
|
describe('with Pepe enabled', () => {
|
|
|
|
it('renders the banner', () => {
|
|
|
|
const store = {
|
|
|
|
instance: normalizeInstance({ registrations: false }),
|
|
|
|
soapbox: fromJS({ extensions: { pepe: { enabled: true } } }),
|
|
|
|
verification: { instance: fromJS({ registrations: true }) },
|
|
|
|
};
|
|
|
|
|
|
|
|
render(<CtaBanner />, undefined, store);
|
|
|
|
expect(screen.getByTestId('cta-banner')).toHaveTextContent(/sign up/i);
|
|
|
|
});
|
|
|
|
});
|
2022-05-10 03:17:01 -07:00
|
|
|
});
|