Skip to content

Commit

Permalink
fixed some regression in test
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Nov 28, 2016
1 parent 8957e55 commit ee8441c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/api/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function runInAction<T>(arg1, arg2?, arg3?) {
invariant(fn.length === 0, "`runInAction` expects a function without arguments");
invariant(typeof actionName === "string" && actionName.length > 0, `actions should have valid names, got: '${actionName}'`);

return executeAction(actionName, fn, scope);
return executeAction(actionName, fn, scope, undefined);
}

export function isAction(thing: any) {
Expand Down
31 changes: 16 additions & 15 deletions test/spy.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
"use strict"
var test = require('tape');
var mobx = require('..');

test('spy output', t => {
var events = [];

var stop = mobx.spy(c => events.push(c));

doStuff();

stop();
doStuff();

doStuff();

events.forEach(ev => { delete ev.object; delete ev.fn; delete ev.time; });

t.equal(events.length, doStuffEvents.length, "amount of events doesn't match");
//t.deepEqual(events, doStuffEvents);

Expand All @@ -35,7 +36,7 @@ test('spy output', t => {
function doStuff() {
var a = mobx.observable(2);
a.set(3);

var b = mobx.observable({
c: 4
});
Expand All @@ -47,27 +48,27 @@ function doStuff() {
e.push(3, 4);
e.shift();
e[2] = 5;

var f = mobx.map({ g: 1 });
f.delete("h");
f.delete("g");
f.set("i", 5);
f.set("i", 6);

var j = mobx.computed(() => a.get() * 2);

var stop = mobx.autorun(() => { j.get() });

a.set(4);

mobx.transaction(function myTransaction() {
a.set(5);
a.set(6);
});

mobx.action("myTestAction", (newValue) => {
a.set(newValue)
})(7);
}).call({}, 7);
}


Expand Down Expand Up @@ -121,7 +122,7 @@ const doStuffEvents = [
{ spyReportStart: true, type: 'reaction' },
{ spyReportEnd: true },
{ spyReportEnd: true },
{ name: 'myTestAction', spyReportStart: true, arguments: [7], type: 'action', target: undefined },
{ name: 'myTestAction', spyReportStart: true, arguments: [7], type: 'action', target: {} },
{ newValue: 7, oldValue: 6, spyReportStart: true, type: 'update' },
{ spyReportEnd: true },
{ target: undefined, type: 'compute' },
Expand Down

0 comments on commit ee8441c

Please sign in to comment.