pleroma/app/soapbox/features/ui/components/__tests__/cta-banner.test.tsx

48 lines
1.5 KiB
TypeScript
Raw Normal View History

import { fromJS } from 'immutable';
2022-05-10 03:17:01 -07:00
import React from 'react';
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);
});
});
describe('with registrations closed', () => {
2022-05-10 03:17:01 -07:00
it('renders empty', () => {
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);
});
});
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
});