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
|
import QtQuick 2.0
import QtTest 1.0
import QuickFlux 1.1
TestCase {
name : "StoreBridgeTests"
property var seq: new Array;
ActionCreator {
id: defaultActionCreator
signal test1();
}
ActionCreator {
id: actionCreator
dispatcher: Dispatcher {}
signal test1
}
Store {
id: store1
property int test1: 0
Filter {
type: "test1"
onDispatched: {
store1.test1++;
seq.push("store1");
}
}
}
Store {
id: store2
property int test1: 0
Filter {
type: "test1"
onDispatched: {
store2.test1++;
seq.push("store2");
}
}
}
Store {
id: rootStore
property int test1: 0
redispatchTargets: [
store1,
store2
]
Filter {
type: "test1"
onDispatched: {
rootStore.test1++;
seq.push("store");
}
}
}
function test_dispatch() {
compare(store1.bindSource, null);
compare(store2.bindSource, null);
rootStore.dispatch("test1");
compare(rootStore.test1, 1);
compare(store1.test1, 1);
compare(store2.test1, 1);
compare(seq,["store1", "store2", "store"]);
rootStore.bind(actionCreator);
defaultActionCreator.test1();
compare(rootStore.test1, 1);
compare(store1.test1, 1);
compare(store2.test1, 1);
compare(seq,["store1", "store2", "store"]);
actionCreator.test1();
compare(rootStore.test1, 2);
compare(store1.test1, 2);
compare(store2.test1, 2);
compare(seq,["store1", "store2", "store", "store1", "store2", "store"]);
}
}
|