Fixed missing initial values when editing one domain redirects

This commit is contained in:
Alejandro Celaya
2021-08-24 20:24:34 +02:00
parent 0804322a9f
commit 06f4cff97e
2 changed files with 23 additions and 5 deletions

View File

@@ -9,7 +9,12 @@ describe('<EditDomainRedirectsModal />', () => {
let wrapper: ShallowWrapper;
const editDomainRedirects = jest.fn().mockResolvedValue(undefined);
const toggle = jest.fn();
const domain = Mock.of<ShlinkDomain>({ domain: 'foo.com' });
const domain = Mock.of<ShlinkDomain>({
domain: 'foo.com',
redirects: {
baseUrlRedirect: 'baz',
},
});
beforeEach(() => {
wrapper = shallow(
@@ -51,7 +56,7 @@ describe('<EditDomainRedirectsModal />', () => {
wrapper.find('form').simulate('submit', { preventDefault: jest.fn() });
expect(editDomainRedirects).toHaveBeenCalledWith('foo.com', {
baseUrlRedirect: null,
baseUrlRedirect: 'baz',
regular404Redirect: null,
invalidShortUrlRedirect: null,
});
@@ -75,5 +80,16 @@ describe('<EditDomainRedirectsModal />', () => {
regular404Redirect: 'new_regular_404',
invalidShortUrlRedirect: null,
});
formGroups.at(0).simulate('change', '');
formGroups.at(1).simulate('change', '');
formGroups.at(2).simulate('change', '');
wrapper.find('form').simulate('submit', { preventDefault: jest.fn() });
expect(editDomainRedirects).toHaveBeenCalledWith('foo.com', {
baseUrlRedirect: null,
regular404Redirect: null,
invalidShortUrlRedirect: null,
});
});
});