Skip to content

Commit

Permalink
Make test more robust to other tests leaving things in a bad state.
Browse files Browse the repository at this point in the history
  • Loading branch information
n1mmy committed Dec 5, 2013
1 parent d1cb374 commit 3229b36
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/livedata/livedata_test_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Meteor.methods({
}
},
setUserId: function(userId) {
check(userId, String);
check(userId, Match.OneOf(String, null));
this.setUserId(userId);
}
});
Expand Down
6 changes: 6 additions & 0 deletions packages/livedata/livedata_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ if (Meteor.isClient) {
messages.length = 0; // clear messages without creating a new object
};

// make sure we're not already logged in. can happen if accounts
// tests fail oddly.
Meteor.apply("setUserId", [null], {wait: true}, expect(function () {}));

Meteor.subscribe("objectsWithUsers", expect(function() {
expectMessages(1, 0, ["owned by none"]);
Meteor.apply("setUserId", ["1"], {wait: true}, afterFirstSetUserId);
Expand Down Expand Up @@ -406,6 +410,8 @@ if (Meteor.isClient) {
test.isFalse(err);
test.equal(result, "100");
}));
// clean up
Meteor.apply("setUserId", [null], {wait: true}, expect(function () {}));
}
]);
}
Expand Down

0 comments on commit 3229b36

Please sign in to comment.