Created
August 4, 2014 05:47
-
-
Save parris/0431861d64a81ff7f220 to your computer and use it in GitHub Desktop.
Example Mocha ReactJS + CoffeeScript Test
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
Parse = require '../../core/parse' | |
TestUtils = require('react/addons').addons.TestUtils | |
logoutView = require './logout' | |
mediator = require '../../core/mediator' | |
describe 'LogoutView', -> | |
beforeEach -> | |
@container = @document.createElement 'div' | |
@logoutEl = TestUtils.renderIntoDocument <logoutView />, @container | |
describe 'once logout is clicked', -> | |
beforeEach -> | |
@parseLogoutStub = @sinon.stub Parse.User, 'logOut' | |
@logoutMediatorStub = @sinon.stub() | |
mediator.on 'user:loggedOut', @logoutMediatorStub | |
@routerSpy = @sinon.spy(mediator.get('router'), 'goto') | |
TestUtils.Simulate.click @logoutEl.getDOMNode() | |
afterEach -> | |
@parseLogoutStub.restore() | |
@routerSpy.restore() | |
it 'logs users out via parse', -> | |
@parseLogoutStub.called.should.be.ok | |
it 'triggers a global logout event', -> | |
@logoutMediatorStub.called.should.be.ok | |
it 'routes to /session', -> | |
@routerSpy.called.should.be.ok |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment