-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtracker.test.ts
More file actions
56 lines (46 loc) · 1.32 KB
/
tracker.test.ts
File metadata and controls
56 lines (46 loc) · 1.32 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
import { should } from 'chai'; should();
import { Subscription } from 'rxjs';
import { Tracker } from '../tracker';
import { isClearable } from '../clearable';
describe('Tracker', () => {
it('should be clearable.', () => {
isClearable(new Tracker()).should.be.true;
});
it('should unsubscribe tracked subscriptions when cleared.', done => {
class T extends Tracker {
constructor() {
super();
this.track(new Subscription(() => done()));
};
}
new T().clear();
});
describe('.untrack()', () => {
it('should remove subscription from tracked subscriptions.', done => {
class T extends Tracker {
constructor() {
super();
this.track(new Subscription(() => done()));
//
// if this does not remove the sub, done() will be called twice.
//
this.untrack(this.track(new Subscription(() => done())));
};
}
new T().clear();
});
});
describe('.tracking', () => {
it('should return true when something is being tracked, false otherwise.', () => {
class T extends Tracker {
constructor() {
super();
this.tracking.should.be.false;
this.track(new Subscription());
this.tracking.should.be.true;
}
}
new T();
});
});
});