Skip to content
Browse files

Improve test isolation in livedata_tests.

  • Loading branch information...
1 parent 6c19b05 commit e93e35ce08c7246d1d3fab6becb0c4bd22f7979e @glasser glasser committed
Showing with 18 additions and 18 deletions.
  1. +6 −6 packages/livedata/livedata_test_service.js
  2. +12 −12 packages/livedata/livedata_tests.js
View
12 packages/livedata/livedata_test_service.js
@@ -133,11 +133,11 @@ if (Meteor.isServer) {
});
(function () {
- var userIdWhenStopped = null;
- Meteor.publish("recordUserIdOnStop", function() {
- var self = this;
+ var userIdWhenStopped = {};
+ Meteor.publish("recordUserIdOnStop", function (key) {
+ var self = this;
self.onStop(function() {
- userIdWhenStopped = self.userId;
+ userIdWhenStopped[key] = self.userId;
});
});
@@ -145,8 +145,8 @@ if (Meteor.isServer) {
setUserId: function(userId) {
this.setUserId(userId);
},
- userIdWhenStopped: function() {
- return userIdWhenStopped;
+ userIdWhenStopped: function (key) {
+ return userIdWhenStopped[key];
}
});
})();
View
24 packages/livedata/livedata_tests.js
@@ -285,9 +285,9 @@ var eavesdropOnCollection = function(livedata_connection,
};
};
-testAsyncMulti("livedata - changing userid reruns subscriptions without flapping data on the wire", [
- function(test, expect) {
- if (Meteor.isClient) {
+if (Meteor.isClient) {
+ testAsyncMulti("livedata - changing userid reruns subscriptions without flapping data on the wire", [
+ function(test, expect) {
var messages = [];
var undoEavesdrop = eavesdropOnCollection(
Meteor.default_connection, "objectsWithUsers", messages);
@@ -342,18 +342,18 @@ testAsyncMulti("livedata - changing userid reruns subscriptions without flapping
test.equal(objectsWithUsers.find().count(), 4);
undoEavesdrop();
});
- }
- }, function(test, expect) {
- if (Meteor.isClient) {
- Meteor.subscribe("recordUserIdOnStop");
- Meteor.apply("setUserId", [100], {wait: true}, expect(function() {}));
- Meteor.apply("setUserId", [101], {wait: true}, expect(function() {}));
- Meteor.call("userIdWhenStopped", expect(function(err, result) {
+ }, function(test, expect) {
+ var key = Meteor.uuid();
+ Meteor.subscribe("recordUserIdOnStop", key);
+ Meteor.apply("setUserId", [100], {wait: true}, expect(function () {}));
+ Meteor.apply("setUserId", [101], {wait: true}, expect(function () {}));
+ Meteor.call("userIdWhenStopped", key, expect(function (err, result) {
+ test.isFalse(err);
test.equal(result, 100);
}));
}
- }
-]);
+ ]);
+}
Tinytest.add("livedata - setUserId error when called from server", function(test) {
if (Meteor.isServer) {

0 comments on commit e93e35c

Please sign in to comment.
Something went wrong with that request. Please try again.