add unit test

This commit is contained in:
Ashfame 2022-12-21 14:25:34 +04:00
parent 898c1349c9
commit f0086a76c8

View File

@ -54,3 +54,17 @@ export async function lookupHomeserver(homeserver, request) {
}
return homeserver;
}
export function tests() {
return {
"normalizing homeserver": assert => {
assert.equal(normalizeHomeserver('matrix.org'), 'https://matrix.org');
assert.equal(normalizeHomeserver('matrix.org:8008'), 'https://matrix.org:8008');
assert.equal(normalizeHomeserver('https://matrix.org'), 'https://matrix.org');
assert.equal(normalizeHomeserver('https://matrix.org:8008'), 'https://matrix.org:8008');
assert.equal(normalizeHomeserver('localhost'), 'https://localhost');
assert.equal(normalizeHomeserver('http:// invalid'), '');
assert.equal(normalizeHomeserver('inv alid'), '');
},
}
}