Ensured all dots are replaced from domain when generating its domain ID

This commit is contained in:
Alejandro Celaya
2021-09-27 22:50:12 +02:00
parent 15b7fd5c93
commit 0cbba1182f
3 changed files with 32 additions and 5 deletions

View File

@@ -17,9 +17,15 @@ describe('<DomainRow />', () => {
afterEach(() => wrapper?.unmount());
it.each([
[ Mock.of<ShlinkDomain>({ domain: '', isDefault: true }), 1 ],
[ Mock.of<ShlinkDomain>({ domain: '', isDefault: false }), 0 ],
])('shows proper components based on the fact that provided domain is default or not', (domain, expectedComps) => {
[ Mock.of<ShlinkDomain>({ domain: '', isDefault: true }), 1, 'domainEdit' ],
[ Mock.of<ShlinkDomain>({ domain: '', isDefault: false }), 0, '' ],
[ Mock.of<ShlinkDomain>({ domain: 'foo.com', isDefault: true }), 1, 'domainEditfoocom' ],
[ Mock.of<ShlinkDomain>({ domain: 'foo.bar.com', isDefault: true }), 1, 'domainEditfoobarcom' ],
])('shows proper components based on the fact that provided domain is default or not', (
domain,
expectedComps,
expectedDomainId,
) => {
const wrapper = createWrapper(domain);
const defaultDomainComp = wrapper.find('td').first().find('DefaultDomain');
const tooltip = wrapper.find(UncontrolledTooltip);
@@ -27,9 +33,13 @@ describe('<DomainRow />', () => {
const icon = wrapper.find(FontAwesomeIcon);
expect(defaultDomainComp).toHaveLength(expectedComps);
expect(tooltip).toHaveLength(expectedComps);
expect(button.prop('disabled')).toEqual(domain.isDefault);
expect(icon.prop('icon')).toEqual(domain.isDefault ? forbiddenIcon : editIcon);
expect(tooltip).toHaveLength(expectedComps);
if (expectedComps > 0) {
expect(tooltip.prop('target')).toEqual(expectedDomainId);
}
});
it.each([