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