-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
33 lines (26 loc) · 1.41 KB
/
test.js
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
'use strict';
var assert = require('assert');
var tweetFormatter = require('./tweet-formatter');
it('should return properly formatted username', function () {
assert.equal('<a href="http://instagram.com/pveyes">@pveyes</a>', tweetFormatter('@pveyes'));
assert.equal('a@pveyes', tweetFormatter('a@pveyes'));
});
it('should return properly formatted hashtag', function () {
assert.equal('<a href="https://twitter.com/search?q=%23hashtag&src=hash">#hashtag</a>', tweetFormatter('#hashtag'));
assert.equal('invalid#hashtag', tweetFormatter('invalid#hashtag'));
});
it('should return properly formatted URL', function () {
var URL1 = 'https://google.com';
assert.equal('<a href="https://google.com">https://google.com</a>', tweetFormatter(URL1));
var URL2 = 'ftp://google.com/~';
assert.equal('<a href="ftp://google.com/~">ftp://google.com/~</a>', tweetFormatter(URL2));
var invalidURL1 = 'ftpx:///~';
assert.equal('ftpx:///~', tweetFormatter(invalidURL1));
var invalidURL2 = 'https:';
assert.equal('https:', tweetFormatter(invalidURL2));
});
it('should return properly formatted tweet', function () {
var tweet1 = 'test #hashtag by @pveyes with url https://google.com'
var result1 = 'test <a href="https://twitter.com/search?q=%23hashtag&src=hash">#hashtag</a> by <a href="http://instagram.com/pveyes">@pveyes</a> with url <a href="https://google.com">https://google.com</a>';
assert.equal(result1, tweetFormatter(tweet1));
});