make toPuny work better in testing

This commit is contained in:
dakkar 2025-04-21 14:58:22 +01:00
parent 58c0ac6c89
commit fda71c4147
2 changed files with 32 additions and 2 deletions

View file

@ -22,6 +22,12 @@ describe('UtilityService', () => {
test('japanese', () => {
assert.equal(utilityService.punyHost('http://www.新聞.com'), 'www.xn--efvv70d.com');
});
test('simple, with port', () => {
assert.equal(utilityService.punyHost('http://www.foo.com:3000'), 'www.foo.com:3000');
});
test('japanese, with port', () => {
assert.equal(utilityService.punyHost('http://www.新聞.com:3000'), 'www.xn--efvv70d.com:3000');
});
});
describe('punyHostPSLDomain', () => {
@ -31,6 +37,12 @@ describe('UtilityService', () => {
test('japanese', () => {
assert.equal(utilityService.punyHostPSLDomain('http://www.新聞.com'), 'xn--efvv70d.com');
});
test('simple, with port', () => {
assert.equal(utilityService.punyHostPSLDomain('http://www.foo.com:3000'), 'foo.com:3000');
});
test('japanese, with port', () => {
assert.equal(utilityService.punyHostPSLDomain('http://www.新聞.com:3000'), 'xn--efvv70d.com:3000');
});
test('lower', () => {
assert.equal(utilityService.punyHostPSLDomain('http://foo.github.io'), 'foo.github.io');
assert.equal(utilityService.punyHostPSLDomain('http://foo.bar.github.io'), 'bar.github.io');
@ -40,4 +52,13 @@ describe('UtilityService', () => {
assert.equal(utilityService.punyHostPSLDomain('http://foo.bar.masto.host'), 'bar.masto.host');
});
});
describe('toPuny', () => {
test('without port ', () => {
assert.equal(utilityService.toPuny('www.foo.com'), 'www.foo.com');
});
test('with port ', () => {
assert.equal(utilityService.toPuny('www.foo.com:3000'), 'www.foo.com:3000');
});
});
});