Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

87 lines (74 sloc) 2.92 KB
{ assert, brains, Browser } = require("./helpers")
describe "Facebook Connect", ->
before (done)->
brains.get "/facebook", (req, res)->
res.send """
window.fbAsyncInit = function() {
appId : "190950381025985",
status : true,
cookie : true,
xfbml : true,
oauth : true,
channelUrl : "http://localhost:3003/facebook/channel"
document.getElementById("connect").addEventListener("click", function(event) {
window.FB.login(function(response) {
window.connected = response.authResponse;
var authResponse = window.FB.getAuthResponse();
if (authResponse)
window.connected = authResponse;
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); = id; js.async = true;
js.src = "//";
<div id="fb-root"></div>
<a id="connect">Connect</a>
brains.ready done
describe "initial", ->
browser = new Browser()
before (done)->
.then ->
browser.clickLink "Connect"
.then done
it "should show FB Connect login form", ->
assert browser.query(".login_form_container #loginform")
describe "login", ->
before (done)->
browser.fill("email", "---").fill("pass", "---")
browser.pressButton "login", done
it "should show permission dialog", ->
assert button = browser.query("#platform_dialog_content #grant_clicked input")
assert.equal button.value, "Log In with Facebook"
describe "authorize", ->
before (done)->
# all.js sets a callback with a different ID on each run. Our
# HTTP/S responses were captured with the callback ID f42febd2c.
# So we cheat by using this ID and linking it to whatver callback
# was registered last.
FB =
for id, fn of FB.XD._callbacks
FB.XD._callbacks["f42febd2c"] = fn
browser.pressButton "Log In with Facebook", ->
# Go back to the first window
it "should log user in", ->
assert.equal browser.window.connected.userID, "100001620738919"
assert browser.window.connected.accessToken
Jump to Line
Something went wrong with that request. Please try again.