1 |
|
2 | var Locker = require("../../lib/locker");
|
3 |
|
4 | describe ("Locker", function() {
|
5 |
|
6 | it ("should lock a page", function() {
|
7 | Locker.lock("antani", {});
|
8 | expect(Locker.getLock("antani")).not.be.a("null");
|
9 | expect(Locker.getLock("antani2")).to.be.a("null");
|
10 | });
|
11 |
|
12 | it ("should unlock a page", function() {
|
13 | Locker.lock("antani", {});
|
14 | Locker.unlock("antani");
|
15 | expect(Locker.getLock("antani")).to.be.a("null")
|
16 | });
|
17 |
|
18 | it ("should reset the locks", function() {
|
19 | Locker.lock("antani1", {});
|
20 | Locker.lock("antani2", {});
|
21 | expect(Locker.count()).to.equal(2);
|
22 | Locker.reset();
|
23 | expect(Locker.count()).to.equal(0);
|
24 | });
|
25 |
|
26 | it ("should purge old locks", function() {
|
27 | Locker.lock("antani1", {});
|
28 | Locker.lock("antani2", {});
|
29 | Locker.purge();
|
30 | expect(Locker.count()).to.equal(2);
|
31 | var lock = Locker.getLock("antani2");
|
32 | lock.ts = lock.ts - (Locker.purgeTime + 1);
|
33 | Locker.purge();
|
34 | expect(Locker.count()).to.equal(1);
|
35 | });
|
36 |
|
37 | }); |
\ | No newline at end of file |