forked from caniszczyk/twlinkfy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
45 lines (40 loc) · 1.54 KB
/
test.html
File metadata and controls
45 lines (40 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Twlinkfy Tests</title>
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css">
<script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
<script src="ext/src/twlinkfy.js"></script>
<script>
function id(value) {
return document.getElementById(value);
}
test('Do not match an already linked username', function() {
var node = id('do-not-match-twitter-linkified-username');
var nodes = getNodes(node);
equal(nodes.length, 0, 'No nodes found');
});
test('Do not match in a text area', function() {
var node = id('do-not-match-twitter-in-textarea');
var nodes = getNodes(node);
equal(nodes.length, 0, 'No nodes found');
});
test('Match twitter username', function() {
var node = id('match-twitter-username');
equal(node.innerHTML, '@cra alw@ys testing', "Usernames with no links");
var nodes = getNodes(node);
replaceNodes(nodes);
equal(node.innerHTML, '<span><a href=\"https://twitter.com/intent/user?screen_name=@cra\">@cra</a> alw@ys testing</span>');
});
</script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">
<p id="match-twitter-username">@cra alw@ys testing</p>
<p id="do-not-match-twitter-linkified-username"><a href="http://twitter.com/cra">@cra</a></p>
<p id="do-not-match-twitter-in-textarea"><textarea>@cra</textarea></p>
</div>
</body>
</html>