Created
January 23, 2014 04:47
-
-
Save simonexmachina/8572983 to your computer and use it in GitHub Desktop.
moduleFor() usage
This file contains hidden or 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
import api from 'mn/utils/api'; | |
import {moduleFor, test} from 'mn/tests/helpers/module_for'; | |
var App, sandbox; | |
moduleFor('controller:login', 'Acceptances - Login', { | |
setup: function() { | |
App = startApp(); | |
sandbox = sinon.sandbox.create(); | |
}, | |
teardown: function() { | |
Ember.run(App, 'destroy'); | |
sandbox.restore(); | |
} | |
}); | |
test('user can login', function() { | |
expect(3); | |
var that = this; | |
visit('/login').then(function() { | |
var loginController = that.subject(), | |
username = find('input[name="username"]'), | |
password = find('input[name="password"]'); | |
equal(username.length, 1); | |
equal(password.length, 1); | |
sandbox.stub(api, 'authenticate', function() { | |
return Ember.RSVP.resolve({ | |
token: 'thetoken', | |
user: { | |
login: 'login', | |
firstName: 'Batman' | |
} | |
}); | |
}); | |
stop(); | |
loginController.addObserver('token', function() { | |
start(); | |
ok(loginController.get('token')); | |
}); | |
Em.run(function () { | |
find('form').submit(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment