2020-08-30 19:45:17 +02:00
|
|
|
import { shallow, ShallowWrapper } from 'enzyme';
|
|
|
|
import { Mock } from 'ts-mockery';
|
2018-12-17 23:11:55 +01:00
|
|
|
import createShortUrlsCreator from '../../src/short-urls/CreateShortUrl';
|
2020-08-30 19:45:17 +02:00
|
|
|
import { ShortUrlCreation } from '../../src/short-urls/reducers/shortUrlCreation';
|
2021-02-14 13:23:42 +01:00
|
|
|
import { Settings } from '../../src/settings/reducers/settings';
|
2018-11-01 13:15:09 +01:00
|
|
|
|
|
|
|
describe('<CreateShortUrl />', () => {
|
2020-08-30 19:45:17 +02:00
|
|
|
let wrapper: ShallowWrapper;
|
2021-03-19 19:11:27 +01:00
|
|
|
const ShortUrlForm = () => null;
|
|
|
|
const CreateShortUrlResult = () => null;
|
2021-02-14 13:23:42 +01:00
|
|
|
const shortUrlCreation = { validateUrls: true };
|
2020-08-30 19:45:17 +02:00
|
|
|
const shortUrlCreationResult = Mock.all<ShortUrlCreation>();
|
|
|
|
const createShortUrl = jest.fn(async () => Promise.resolve());
|
2018-11-01 13:15:09 +01:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2021-03-19 19:11:27 +01:00
|
|
|
const CreateShortUrl = createShortUrlsCreator(ShortUrlForm, CreateShortUrlResult);
|
2018-12-17 23:11:55 +01:00
|
|
|
|
2018-11-01 13:15:09 +01:00
|
|
|
wrapper = shallow(
|
2020-08-30 19:45:17 +02:00
|
|
|
<CreateShortUrl
|
|
|
|
shortUrlCreationResult={shortUrlCreationResult}
|
|
|
|
createShortUrl={createShortUrl}
|
|
|
|
selectedServer={null}
|
|
|
|
resetCreateShortUrl={() => {}}
|
2021-02-14 13:23:42 +01:00
|
|
|
settings={Mock.of<Settings>({ shortUrlCreation })}
|
2020-08-30 19:45:17 +02:00
|
|
|
/>,
|
2018-11-01 13:15:09 +01:00
|
|
|
);
|
|
|
|
});
|
2020-08-30 19:45:17 +02:00
|
|
|
afterEach(() => wrapper.unmount());
|
|
|
|
afterEach(jest.clearAllMocks);
|
2018-11-01 13:15:09 +01:00
|
|
|
|
2021-03-19 19:11:27 +01:00
|
|
|
it('renders a ShortUrlForm with a computed initial state', () => {
|
|
|
|
const form = wrapper.find(ShortUrlForm);
|
|
|
|
const result = wrapper.find(CreateShortUrlResult);
|
2018-11-01 13:15:09 +01:00
|
|
|
|
2021-03-19 19:11:27 +01:00
|
|
|
expect(form).toHaveLength(1);
|
|
|
|
expect(result).toHaveLength(1);
|
2018-11-01 13:15:09 +01:00
|
|
|
});
|
|
|
|
});
|