Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ramseydsilva committed Apr 4, 2014
1 parent 944bf47 commit c3fce6c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Socket.io utility for testing socket.io/node applications.
This lib provides two methods:

1. anonSocket
1. authSocket
2. authSocket

### anonSocket

Expand All @@ -23,11 +23,12 @@ use to poll your server as an anonymous user.
var socketer = request('socketer');
socketer.anonSocket(app, function(socket) {
socket.on('connect', function() {
socket.once('connect', function() {
console.log('I am connected!');
});
socket.on('my-event', function() {
socket.once('my-event', function() {
console.log('My event is happening');
socket.disconnect(); // Call this to disconnect after your function to uninterupt further connect events
});
};
```
Expand All @@ -41,20 +42,28 @@ callback that returns an anonymous socket that you can use to poll your server a
var socketer = request('socketer');
socketer.authSocket(app, {'username': 'Ramsey', 'password': 'Ramseypass'}, '/login', function(socket) {
socket.on('connect', function() {
socket.once('connect', function() {
console.log('I am connected as Ramsey!');
});
});
```

## Tips

1. After every test and before you call the done method, you can choose to disconnect the socket by calling
`socket.disconnect();`. This ensures uninterupted successive socket reconnects.
2. Instead of using `socket.on(event)`, consider using `socket.once(event)` in your tests. This ensures the event
listener stops listening if the event occurs in successive tests.


## Requirements

This library simulates the a client socket using socket.io-client package. Different versions of this package might
differ in its implementation. During the time time of writing this lib, the versions I was using was:

1. express: ~3.5.1
1. socket.io: ~0.9.16
1. socket.io-client: ^0.9.16
2. socket.io: ~0.9.16
3. socket.io-client: ^0.9.16

## Issues

Expand Down

0 comments on commit c3fce6c

Please sign in to comment.