forked from leancloud/javascript-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcache.js
More file actions
23 lines (22 loc) · 656 Bytes
/
Copy pathcache.js
File metadata and controls
23 lines (22 loc) · 656 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var Cache = AV.Cache;
var wait = function wait(time) {
return new Promise(function (resolve) {
return setTimeout(resolve, time);
});
};
describe('Cache async', function () {
var getValue = function getValue() {
return Cache.getAsync('__test');
};
it('get/set async', function () {
return Cache.setAsync('__test', 1).then(getValue).then(function (value) {
expect(value).to.be(1);
return Cache.setAsync('__test', '1', 100).then(getValue);
}).then(function (value) {
expect(value).to.be('1');
return wait(110).then(getValue);
}).then(function (value) {
expect(value).to.be(null);
});
});
});