index-spec.js
1.29 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
46
47
48
49
50
51
52
53
54
55
56
57
58
var expect = require('expect.js');
//var yasJssdk = require('../yas');
//工具库
var util = require('../src/util');
//cookie处理
var cookies = require('../src/cookie');
//跨域通信
var cross = require('../src/cross');
//事件处理
var ev = require('../src/event');
var config = require('../src/config');
describe('yas-jssdk', function() {
it('cookies 测试', function() {
cookies('a','1',{path:"/",domain:config.yasDomain,expires:365*200});
expect(cookies('a')).to.equal('1');
cookies('a',null,{path:"/",domain:config.yasDomain,expires:365*200});
expect(cookies('a')).to.equal(null);
});
it('util 测试', function() {
var ret = util.merge({a:1},{b:2});
expect(ret.a).to.equal(1);
expect(ret.b).to.equal(2);
var url = util.genParam(ret);
expect(url).to.equal('a=1&b=2');
var string = util.trim(' fsdf fsdf fdsf ');
expect(string).to.equal('fsdf fsdf fdsf');
var a = util.hashClientInfo();
var b = util.hashClientInfo();
expect(a).to.be(b);
});
it('ev 测试',function()
{
var i=0;
function add()
{
i=2;
}
ev.addEventHandler(document,'load',add);
window.setTimeout(function()
{
expect(i).to.be(2);
},1000);
ev.removeEventHandler(document,'load',add);
});
});