Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Add ipv4 and ip v6 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariusz Niemczyk committed Dec 3, 2021
1 parent 1fa6f5a commit 7db8664
Showing 1 changed file with 45 additions and 8 deletions.
53 changes: 45 additions & 8 deletions test/linkify-matrix-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('linkify-matrix', () => {
*/
function genTests(char: '#' | '@' | '+') {
const type = linkTypesByInitialCharacter[char];
it.skip('should not parse ' + char + 'foo without domain', () => {
it('should not parse ' + char + 'foo without domain', () => {
const test = char + "foo";
const found = linkify.find(test);
expect(found).toEqual(([]));
Expand Down Expand Up @@ -72,11 +72,48 @@ describe('linkify-matrix', () => {
}]));
});
});
describe('ip v6 tests', () => {
it.only('should properly parse IPs v6 as the domain name', () => {
const test = char + "[1234:5678::abcd]";
// Currently those tests are failing, as there's missing implementation.
describe.skip('ip v6 tests', () => {
it('should properly parse IPs v6 as the domain name', () => {
const test = char + "username:[1234:5678::abcd]";
const found = linkify.find(test);
expect(found).toEqual(([]));
expect(found).toEqual([{
href: char + 'username:[1234:5678::abcd]',
type,
isLink: true,
start: 0,
end: test.length,
value: char + 'username:[1234:5678::abcd]',
},
]);
});

it('should properly parse IPs v6 with port as the domain name', () => {
const test = char + "username:[1234:5678::abcd]:1337";
const found = linkify.find(test);
expect(found).toEqual([{
href: char + 'username:[1234:5678::abcd]:1337',
type,
isLink: true,
start: 0,
end: test.length,
value: char + 'username:[1234:5678::abcd]:1337',
},
]);
});
// eslint-disable-next-line max-len
it('should properly parse IPs v6 while ignoring dangling comma when without port name as the domain name', () => {
const test = char + "username:[1234:5678::abcd]:";
const found = linkify.find(test);
expect(found).toEqual([{
href: char + 'username:[1234:5678::abcd]:',
type,
isLink: true,
start: 0,
end: test.length - 1,
value: char + 'username:[1234:5678::abcd]:',
},
]);
});
});
it('properly parses ' + char + '_foonetic_xkcd:matrix.org', () => {
Expand Down Expand Up @@ -225,15 +262,15 @@ describe('linkify-matrix', () => {
});
}

describe('roomalias', () => {
describe('roomalias plugin', () => {
genTests('#');
});

describe('groupid', () => {
describe('groupid plugin', () => {
genTests('+');
});

describe('userid', () => {
describe('userid plugin', () => {
genTests('@');
});
});

0 comments on commit 7db8664

Please sign in to comment.