1 | const log = getLogger(__filename)
|
2 | log.info('Starting test suite')
|
3 |
|
4 | import {SyncStrategy,CoordinatorOptions} from "../Types";
|
5 | import {NullStore} from "./fixtures/NullStore"
|
6 | import {Coordinator} from '../Coordinator'
|
7 | import {TypeStoreModelKey,TypeStoreAttrKey} from '../Constants'
|
8 | import * as Fixtures from './fixtures/Fixtures'
|
9 |
|
10 |
|
11 | let coordinator:Coordinator = null
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | async function reset(syncStrategy:SyncStrategy) {
|
20 |
|
21 | log.info('Coordinator reset, now init')
|
22 | if (coordinator)
|
23 | await coordinator.stop()
|
24 |
|
25 | coordinator = new Coordinator()
|
26 | return await coordinator.init(new CoordinatorOptions({syncStrategy}),new NullStore())
|
27 |
|
28 | }
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | describe('#typestore-model-decorations',() => {
|
35 |
|
36 | beforeEach(() => {
|
37 | return reset(SyncStrategy.None)
|
38 | })
|
39 |
|
40 | it('#model', async () => {
|
41 | await coordinator.start(Fixtures.ModelTest1)
|
42 |
|
43 |
|
44 |
|
45 | const constructorFn = Fixtures.ModelTest1
|
46 | expect(constructorFn).toBe(Fixtures.ModelTest1)
|
47 |
|
48 | const attrData = Reflect.getOwnMetadata(TypeStoreAttrKey,constructorFn),
|
49 | modelData = Reflect.getOwnMetadata(TypeStoreModelKey,constructorFn)
|
50 |
|
51 |
|
52 | expect(attrData.length).toEqual(3)
|
53 | expect(modelData.attrs.length).toEqual(3)
|
54 | })
|
55 |
|
56 | })
|
57 |
|