Skip to content

Instantly share code, notes, and snippets.

@samiy-xx
Created January 25, 2013 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samiy-xx/4633283 to your computer and use it in GitHub Desktop.
Save samiy-xx/4633283 to your computer and use it in GitHub Desktop.
Async unittesting with Dart on the server side
test("Channel, joining/leaving, fires event", () {
User u = TestFactory.getTestUser(userId, ws);
MockChannelConnectionEventListener l = new MockChannelConnectionEventListener();
c.subscribe(l);
bool wasJoined = false;
bool wasLeft = false;
l.joinCallback = (Channel chan, User user) {
expect(chan, equals(c));
expect(user, equals(u));
wasJoined = true;
};
l.leaveCallback = (Channel chan, User user) {
expect(chan, equals(c));
expect(user, equals(u));
wasLeft = true;
};
c.join(u);
c.leave(u);
Timer t = new Timer(100, (_) {
expect(wasJoined, equals(true));
expect(wasLeft, equals(true));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment