Some more tests
This commit is contained in:
parent
2a806da35c
commit
1c831ad152
|
@ -12,68 +12,97 @@ const Struct = Syndicate.Struct;
|
||||||
|
|
||||||
const Event = Struct.makeConstructor('Event', ['label', 'type', 'values']);
|
const Event = Struct.makeConstructor('Event', ['label', 'type', 'values']);
|
||||||
|
|
||||||
describe('simple list assertions trace', () => {
|
function eventCallback(traceHolder, label) {
|
||||||
let trace = Immutable.List();
|
return (e, vs) => {
|
||||||
|
traceHolder.trace = traceHolder.trace.push(Event(label, e, vs));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function skeletonTrace(f) {
|
||||||
|
let traceHolder = {trace: Immutable.List()};
|
||||||
let i = new Skeleton.Index();
|
let i = new Skeleton.Index();
|
||||||
i.addHandler([3, null, null, null],
|
f(i, traceHolder);
|
||||||
Immutable.fromJS([[0]]),
|
return traceHolder.trace;
|
||||||
Immutable.fromJS(["hi"]),
|
}
|
||||||
Immutable.fromJS([[1],[2]]),
|
|
||||||
(e, vs) => {
|
describe('skeleton tests', () => {
|
||||||
trace = trace.push(Event("3-EVENT", e, vs));
|
|
||||||
});
|
const A = Struct.makeConstructor('A', ['x', 'y']);
|
||||||
i.addHandler([2, null, null],
|
const B = Struct.makeConstructor('B', ['v']);
|
||||||
Immutable.fromJS([]),
|
const C = Struct.makeConstructor('C', ['v']);
|
||||||
Immutable.fromJS([]),
|
|
||||||
Immutable.fromJS([]),
|
describe('simple detail-erasing trace', () => {
|
||||||
(e, vs) => {
|
let trace = skeletonTrace((i, traceHolder) => {
|
||||||
trace = trace.push(Event("2-EVENT", e, vs));
|
i.addHandler([2, null, null],
|
||||||
});
|
Immutable.fromJS([]),
|
||||||
i.addAssertion(Immutable.fromJS(["hi", 123, 234]));
|
Immutable.fromJS([]),
|
||||||
i.addAssertion(Immutable.fromJS(["hi", 999, 999]));
|
Immutable.fromJS([]),
|
||||||
i.addAssertion(Immutable.fromJS(["hi", 123]));
|
eventCallback(traceHolder, "2-EVENT"));
|
||||||
i.addAssertion(Immutable.fromJS(["hi", 123, 234]));
|
|
||||||
i.sendMessage(Immutable.fromJS(["hi", 303]));
|
i.addAssertion(Immutable.fromJS(["hi", 123]));
|
||||||
i.sendMessage(Immutable.fromJS(["hi", 303, 404]));
|
i.addAssertion(Immutable.fromJS(["hi", 234]));
|
||||||
i.sendMessage(Immutable.fromJS(["hi", 303, 404, 808]));
|
i.removeAssertion(Immutable.fromJS(["hi", 123]));
|
||||||
i.removeAssertion(Immutable.fromJS(["hi", 123, 234]));
|
i.removeAssertion(Immutable.fromJS(["hi", 234]));
|
||||||
i.removeAssertion(Immutable.fromJS(["hi", 999, 999]));
|
});
|
||||||
i.removeAssertion(Immutable.fromJS(["hi", 123, 234]));
|
|
||||||
i.addAssertion(Immutable.fromJS(["hi", 123]));
|
it('should have one add and one remove', () => {
|
||||||
i.addAssertion(Immutable.fromJS(["hi", 234]));
|
expect(trace)
|
||||||
i.removeAssertion(Immutable.fromJS(["hi", 123]));
|
.to.equal(Immutable.List([
|
||||||
i.removeAssertion(Immutable.fromJS(["hi", 123]));
|
Event("2-EVENT", Skeleton.EVENT_ADDED, Immutable.List([])),
|
||||||
i.removeAssertion(Immutable.fromJS(["hi", 234]));
|
Event("2-EVENT", Skeleton.EVENT_REMOVED, Immutable.List([]))]));
|
||||||
it('should have 8 entries', () => {
|
});
|
||||||
expect(trace.size).to.equal(8);
|
|
||||||
});
|
});
|
||||||
it('should have two 3-EVENT adds', () => {
|
|
||||||
expect(trace.filter((e) => { return e[0] === "3-EVENT" && e[1] === Skeleton.EVENT_ADDED; }))
|
describe('simple list assertions trace', () => {
|
||||||
.to.equal(Immutable.List([
|
let trace = skeletonTrace((i, traceHolder) => {
|
||||||
Event("3-EVENT", Skeleton.EVENT_ADDED, Immutable.List([123, 234])),
|
i.addHandler([3, null, null, null],
|
||||||
Event("3-EVENT", Skeleton.EVENT_ADDED, Immutable.List([999, 999]))]));
|
Immutable.fromJS([[0]]),
|
||||||
|
Immutable.fromJS(["hi"]),
|
||||||
|
Immutable.fromJS([[1],[2]]),
|
||||||
|
eventCallback(traceHolder, "3-EVENT"));
|
||||||
|
i.addHandler([2, null, null],
|
||||||
|
Immutable.fromJS([]),
|
||||||
|
Immutable.fromJS([]),
|
||||||
|
Immutable.fromJS([]),
|
||||||
|
eventCallback(traceHolder, "2-EVENT"));
|
||||||
|
|
||||||
|
i.addAssertion(Immutable.fromJS(["hi", 123, 234]));
|
||||||
|
i.addAssertion(Immutable.fromJS(["hi", 999, 999]));
|
||||||
|
i.addAssertion(Immutable.fromJS(["hi", 123]));
|
||||||
|
i.addAssertion(Immutable.fromJS(["hi", 123, 234]));
|
||||||
|
i.sendMessage(Immutable.fromJS(["hi", 303]));
|
||||||
|
i.sendMessage(Immutable.fromJS(["hi", 303, 404]));
|
||||||
|
i.sendMessage(Immutable.fromJS(["hi", 303, 404, 808]));
|
||||||
|
i.removeAssertion(Immutable.fromJS(["hi", 123, 234]));
|
||||||
|
i.removeAssertion(Immutable.fromJS(["hi", 999, 999]));
|
||||||
|
i.removeAssertion(Immutable.fromJS(["hi", 123, 234]));
|
||||||
|
i.addAssertion(Immutable.fromJS(["hi", 123]));
|
||||||
|
i.addAssertion(Immutable.fromJS(["hi", 234]));
|
||||||
|
i.removeAssertion(Immutable.fromJS(["hi", 123]));
|
||||||
|
i.removeAssertion(Immutable.fromJS(["hi", 123]));
|
||||||
|
i.removeAssertion(Immutable.fromJS(["hi", 234]));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have 8 entries', () => {
|
||||||
|
expect(trace.size).to.equal(8);
|
||||||
|
});
|
||||||
|
it('should have a correct 3-EVENT subtrace', () => {
|
||||||
|
expect(trace.filter((e) => { return e[0] === "3-EVENT"; }))
|
||||||
|
.to.equal(Immutable.List([
|
||||||
|
Event("3-EVENT", Skeleton.EVENT_ADDED, Immutable.List([123, 234])),
|
||||||
|
Event("3-EVENT", Skeleton.EVENT_ADDED, Immutable.List([999, 999])),
|
||||||
|
Event("3-EVENT", Skeleton.EVENT_MESSAGE, Immutable.List([303, 404])),
|
||||||
|
Event("3-EVENT", Skeleton.EVENT_REMOVED, Immutable.List([999, 999])),
|
||||||
|
Event("3-EVENT", Skeleton.EVENT_REMOVED, Immutable.List([123, 234]))]));
|
||||||
|
});
|
||||||
|
it('should have a correct 2-EVENT subtrace', () => {
|
||||||
|
expect(trace.filter((e) => { return e[0] === "2-EVENT"; }))
|
||||||
|
.to.equal(Immutable.List([
|
||||||
|
Event("2-EVENT", Skeleton.EVENT_ADDED, Immutable.List([])),
|
||||||
|
Event("2-EVENT", Skeleton.EVENT_MESSAGE, Immutable.List([])),
|
||||||
|
Event("2-EVENT", Skeleton.EVENT_REMOVED, Immutable.List([]))]));
|
||||||
|
});
|
||||||
|
// trace.forEach((e) => { console.log(e.toString()) });
|
||||||
});
|
});
|
||||||
it('should have two 3-EVENT removals', () => {
|
|
||||||
expect(trace.filter((e) => { return e[0] === "3-EVENT" && e[1] === Skeleton.EVENT_REMOVED; }))
|
|
||||||
.to.equal(Immutable.List([
|
|
||||||
Event("3-EVENT", Skeleton.EVENT_REMOVED, Immutable.List([999, 999])),
|
|
||||||
Event("3-EVENT", Skeleton.EVENT_REMOVED, Immutable.List([123, 234]))]));
|
|
||||||
});
|
|
||||||
it('should have one 2-EVENT add', () => {
|
|
||||||
expect(trace.filter((e) => { return e[0] === "2-EVENT" && e[1] === Skeleton.EVENT_ADDED; }))
|
|
||||||
.to.equal(Immutable.List([
|
|
||||||
Event("2-EVENT", Skeleton.EVENT_ADDED, Immutable.List([]))]));
|
|
||||||
});
|
|
||||||
it('should have one 2-EVENT removal', () => {
|
|
||||||
expect(trace.filter((e) => { return e[0] === "2-EVENT" && e[1] === Skeleton.EVENT_REMOVED; }))
|
|
||||||
.to.equal(Immutable.List([
|
|
||||||
Event("2-EVENT", Skeleton.EVENT_REMOVED, Immutable.List([]))]));
|
|
||||||
});
|
|
||||||
it('should have two messages', () => {
|
|
||||||
expect(trace.filter((e) => { return e[1] === Skeleton.EVENT_MESSAGE; }))
|
|
||||||
.to.equal(Immutable.List([
|
|
||||||
Event("2-EVENT", Skeleton.EVENT_MESSAGE, Immutable.List([])),
|
|
||||||
Event("3-EVENT", Skeleton.EVENT_MESSAGE, Immutable.List([303, 404]))]));
|
|
||||||
});
|
|
||||||
trace.forEach((e) => { console.log(e.toString()) });
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue