UNPKG

1.3 kBPlain TextView Raw
1const log = getLogger(__filename)
2log.info('Starting test suite')
3
4import {SyncStrategy,CoordinatorOptions} from "../Types";
5import {NullStore} from "./fixtures/NullStore"
6import {Coordinator} from '../Coordinator'
7import {TypeStoreModelKey,TypeStoreAttrKey} from '../Constants'
8import * as Fixtures from './fixtures/Fixtures'
9
10
11let coordinator:Coordinator = null
12
13/**
14 * Reset TypeStore and start all over
15 *
16 * @param syncStrategy
17 * @returns {Bluebird<U>}
18 */
19async 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 * Global test suite
33 */
34describe('#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 //new Fixtures.ModelTest1()
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