-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathcommon.spec.ts
30 lines (27 loc) · 1.11 KB
/
common.spec.ts
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
import { isLive, isCollection, isResource } from './common';
import { ICacheable } from './interfaces/cacheable';
import { Resource } from './resource';
import { DocumentCollection } from './document-collection';
import { DocumentResource } from './document-resource';
describe('common funcions', () => {
it('should be isLive return a correct boolean value', () => {
let cacheable: ICacheable = {
is_loading: false,
loaded: true,
source: 'server',
cache_last_update: Date.now() - 1000 * 1000
};
expect(isLive(cacheable, 100)).toBe(false);
expect(isLive(cacheable, 10000)).toBe(true);
});
let resource = new DocumentResource();
let collection = new DocumentCollection();
it('should be detect DocumentResource with isResource()', () => {
expect(isResource(resource)).toBe(true);
expect(isResource(collection)).toBe(false);
});
it('should be detect DocumentCollection with isCollection()', () => {
expect(isCollection(collection)).toBe(true);
expect(isCollection(resource)).toBe(false);
});
});