-
Notifications
You must be signed in to change notification settings - Fork 0
/
safelink-jquery.js
67 lines (56 loc) · 2.07 KB
/
safelink-jquery.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const assert = require('assert');
const { JSDOM } = require('jsdom');
const { window } = new JSDOM(`<!DOCTYPE html><head></head><body><div id="safelinker1"></div><div id="safelinker2"></div></body></html>`);
describe('jQuery safelink test', function() {
$ = global.jQuery = require('jquery')(window);
require('../src/safelink.js');
it('keyStr standard', function() {
assert.equal($().Safelink().Crypto._keyStr,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=');
});
it('encode value', function() {
assert.equal($().Safelink().encode('abcde'),'YWJjZGU=');
});
it('decode value', function() {
assert.equal($().Safelink().decode('YWJjZGU='),'abcde');
});
it('config value', function() {
$().Safelink({
encoded:'123',
firstButtonText: 'Click here bro!',
secondButtonText: 'Continue to Link!'
});
});
it('build will throws error if not in browser', function() {
assert.throws(function(){
$('#safelinker1').Safelink({
firstButtonText: 'Click here bro!',
secondButtonText: 'Continue to Link!'
}).build('#safelinker2','btn');
},Error);
});
it('build with direct encoded', function() {
$('#safelinker1').Safelink({
encoded:'123',
firstButtonText: 'Click here bro!',
secondButtonText: 'Continue to Link!'
}).build('#safelinker2','btn');
});
it('build with timer', function() {
$('#safelinker1').Safelink({
encoded:'123',
timer: true,
firstButtonText: 'Click here bro!',
secondButtonText: 'Continue to Link!'
}).build('#safelinker2');
});
it('build with custom timer', function() {
$('#safelinker1').Safelink({
encoded:'123',
timer: true,
timer_first:1,
timer_second:1,
firstButtonText: 'Click here bro!',
secondButtonText: 'Continue to Link!'
}).build('#safelinker2');
});
});