/
effects_metadata.spec.ts
44 lines (35 loc) · 1.13 KB
/
effects_metadata.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Effect, getSourceMetadata, getSourceForInstance } from '../src/effects_metadata';
describe('Effect Metadata', () => {
describe('getSourceMetadata', () => {
it('should get the effects metadata for a class instance', () => {
class Fixture {
@Effect() a: any;
@Effect() b: any;
@Effect({ dispatch: false }) c: any;
}
const mock = new Fixture();
expect(getSourceMetadata(mock)).toEqual([
{ propertyName: 'a', dispatch: true },
{ propertyName: 'b', dispatch: true },
{ propertyName: 'c', dispatch: false }
]);
});
it('should return an empty array if the class has not been decorated', () => {
class Fixture {
a: any;
b: any;
c: any;
}
const mock = new Fixture();
expect(getSourceMetadata(mock)).toEqual([]);
});
});
describe('getSourceProto', () => {
it('should get the prototype for an instance of a source', () => {
class Fixture { }
const instance = new Fixture();
const proto = getSourceForInstance(instance);
expect(proto).toBe(Fixture.prototype);
});
});
});