yratanov / ember-cli-mock-socket

Wrapper around https://github.com/thoov/mock-socket for ember-cli
MIT License
1 stars 2 forks source link

Examples of using this in Ember tests? #2

Open jamesdixon opened 9 years ago

jamesdixon commented 9 years ago

Hi,

First off, thanks for turning this into an Ember CLI addon! Appreciated.

Second, do you have any examples of how you're using this in your Ember tests? I'm fairly new to testing and struggling with this a bit.

Thanks! James

yratanov commented 9 years ago

Hi @jamesdixon. It is actually just a wrapper for bower package so:

I add a test helper:

Ember.Test.registerHelper 'stubWebSocket', (app, url)->
  window.WebSocket = MockSocket
  new MockServer(url)

then in tests

webSocketServer = stubWebSocket(user.get('id'))
webSocketServer.send(message)
andThen ->
  assertPageIncludes 'Something on the page after message received'

Sorry for coffeescript, but I think you get the idea.

Mawaheb commented 9 years ago

Could you please be kind and link/add some more tests examples? I am as well finding it difficult to get my tests running