]> git.proxmox.com Git - mirror_xterm.js.git/blob - test/addons/linkify-test.js
Move to TypeScript build
[mirror_xterm.js.git] / test / addons / linkify-test.js
1 var assert = require('chai').assert;
2 var Terminal = require('../../build/xterm');
3 var linkify = require('../../addons/linkify/linkify');
4
5 describe('linkify addon', function () {
6 var xterm;
7
8 describe('API', function () {
9 it('should define Terminal.prototype.linkify', function () {
10 assert.isDefined(Terminal.prototype.linkify);
11 });
12 it('should define Terminal.prototype.linkifyTerminalLine', function () {
13 assert.isDefined(Terminal.prototype.linkifyTerminalLine);
14 });
15 });
16
17 describe('findUrlMatchOnLine', function () {
18 describe('strict regex', function () {
19 it('should match when the entire text is a match', function () {
20 assert.equal(linkify.findLinkMatch('http://github.com', false), 'http://github.com');
21 assert.equal(linkify.findLinkMatch('http://127.0.0.1', false), 'http://127.0.0.1');
22 });
23 it('should match simple domains', function () {
24 assert.equal(linkify.findLinkMatch('foo http://github.com bar', false), 'http://github.com');
25 assert.equal(linkify.findLinkMatch('foo http://www.github.com bar', false), 'http://www.github.com');
26 assert.equal(linkify.findLinkMatch('foo https://github.com bar', false), 'https://github.com');
27 assert.equal(linkify.findLinkMatch('foo https://www.github.com bar', false), 'https://www.github.com');
28 });
29 it('should match web addresses with alpha paths', function () {
30 assert.equal(linkify.findLinkMatch('foo http://github.com/a/b/c bar', false), 'http://github.com/a/b/c');
31 assert.equal(linkify.findLinkMatch('foo http://www.github.com/a/b/c bar', false), 'http://www.github.com/a/b/c');
32 });
33 it('should not include whitespace surrounding a match', function () {
34 assert.equal(linkify.findLinkMatch(' http://github.com', false), 'http://github.com');
35 assert.equal(linkify.findLinkMatch('http://github.com ', false), 'http://github.com');
36 assert.equal(linkify.findLinkMatch(' http://github.com ', false), 'http://github.com');
37 });
38 it('should match IP addresses', function () {
39 assert.equal(linkify.findLinkMatch('foo http://127.0.0.1 bar', false), 'http://127.0.0.1');
40 assert.equal(linkify.findLinkMatch('foo https://127.0.0.1 bar', false), 'https://127.0.0.1');
41 });
42 it('should match ports on both domains and IP addresses', function () {
43 assert.equal(linkify.findLinkMatch('foo http://127.0.0.1:8080 bar', false), 'http://127.0.0.1:8080');
44 assert.equal(linkify.findLinkMatch('foo http://www.github.com:8080 bar', false), 'http://www.github.com:8080');
45 });
46 });
47 });
48 });