Created
January 25, 2013 10:16
-
-
Save samiy-xx/4633283 to your computer and use it in GitHub Desktop.
Async unittesting with Dart on the server side
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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