forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfluxxor-tests.ts
164 lines (129 loc) · 3.61 KB
/
fluxxor-tests.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
///<reference path='fluxxor.d.ts' />
import React = require('react');
import Fluxxor = require('fluxxor');
class DispatcherTest {
v: Fluxxor.Dispatcher;
constructor() {
var stores: Fluxxor.Store[];
this.v = new Fluxxor.Dispatcher(stores);
}
addStore() {
var store: Fluxxor.Store;
var v1: void = this.v.addStore('mystore', store);
}
dispatch() {
var fn = () => console.log(1);
var v1: void = this.v.dispatch(fn);
}
doDispatchLoop() {
var fn = () => console.log(1);
var v1: void = this.v.doDispatchLoop(fn);
}
waitForStores() {
var store: Fluxxor.Store;
var fn = () => console.log(1);
var v1: void = this.v.waitForStores(store, ['mystore1', 'mystore2'], fn);
}
}
class FluxTest {
v: Fluxxor.Flux;
constructor() {
var stores: any;
var actions: any;
this.v = new Fluxxor.Flux(stores, actions);
}
props() {
var stores: any = this.v.stores;
var actions: any = this.v.actions;
}
addActions() {
var actions: any;
var v1: void = this.v.addActions(actions);
}
addAction() {
var fn = () => console.log(1);
// first form
var v1: void = this.v.addAction('action1', fn);
var v2: void = this.v.addAction('action1', 'action2', fn);
// second form
var v3: void = this.v.addAction(['action1'], fn);
var v4: void = this.v.addAction(['action1','action2'], fn);
}
store() {
var store1: any = this.v.store('mystore');
}
addStore() {
var store: Fluxxor.Store;
var v1: void = this.v.addStore('mystore', store);
}
addStores() {
var stores: any;
var v1: void = this.v.addStores(stores);
}
}
class StoreTest {
v: Fluxxor.Store;
bindActions() {
var fn = () => console.log(1);
// first form
var v1: void = this.v.bindActions('action1', fn);
var v2: void = this.v.bindActions(
'action1', fn,
'action2', fn
);
// second form
var v3: void = this.v.bindActions([
'action1', fn,
'action2', fn,
]);
}
waitFor() {
var fn = () => console.log(1);
var v1: void = this.v.waitFor(['mystore1','mystore2'], fn);
}
}
class ContextTest {
v: Fluxxor.Context;
props() {
var v1: Fluxxor.Flux = this.v.flux;
}
}
class FluxMixinTest {
v: Fluxxor.FluxMixin;
constructor() {
this.v = Fluxxor.FluxMixin(React);
}
getFlux() {
var v1: Fluxxor.Flux = this.v.getFlux();
}
}
class FluxChildMixinTest {
v: Fluxxor.FluxChildMixin;
constructor() {
this.v = Fluxxor.FluxChildMixin(React);
}
getFlux() {
var v1: Fluxxor.Flux = this.v.getFlux();
}
}
class StoreWatchMixinTest<StoreState> {
v: Fluxxor.StoreWatchMixin<StoreState>;
constructor() {
this.v = Fluxxor.StoreWatchMixin<StoreState>('store1');
this.v = Fluxxor.StoreWatchMixin<StoreState>('store1','store2');
this.v = Fluxxor.StoreWatchMixin<StoreState>('store1','store2','store3');
}
getStateFromFlux() {
var v1: StoreState = this.v.getStateFromFlux();
}
}
new StoreWatchMixinTest();
new StoreWatchMixinTest<{ a: Fluxxor.Store; }>();
new StoreWatchMixinTest<{ b: Fluxxor.Store; }>();
function createStoreTest() {
var spec: Fluxxor.StoreSpec;
var Class: Fluxxor.StoreClass = Fluxxor.createStore(spec);
var store1: any = new Class();
var store2: any = new Class({value: 1});
}
var versionTest: string = Fluxxor.version;