Skip to content

Instantly share code, notes, and snippets.

@dunn
Created August 20, 2016 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dunn/84309e5ba444d85d33cab925c3f9bbb1 to your computer and use it in GitHub Desktop.
Save dunn/84309e5ba444d85d33cab925c3f9bbb1 to your computer and use it in GitHub Desktop.
const Nightmare = require('nightmare');
const assert = require('assert');
const util = require('util');
require('mocha-generators').install();
if (!process.env['BT_CONFIG_DIR'])
process.env['BT_CONFIG_DIR'] = `${__dirname}/config`;
const user = process.env['BT_TEST_USER'];
const pass = process.env['BT_TEST_PASS'];
describe('signup and login', () => {
it('signs up via Twitter with default settings', function*() {
const nm = Nightmare();
yield nm.goto('http://localhost:3000')
.wait('.container-fluid')
.click('form[action*="/auth/twitter"] [type=submit]')
.wait('.auth')
.type('form[action*="https://api.twitter.com/oauth/authenticate"] [name="session[username_or_email]"]', user)
.type('form[action*="https://api.twitter.com/oauth/authenticate"] [name="session[password]"]', pass)
.click('form[action*="https://api.twitter.com/oauth/authenticate"] [type=submit]')
.wait('.container-fluid')
.evaluate(() => {
return [
document.querySelector('.container-fluid p:nth-child(4) input').checked,
document.querySelector('.container-fluid p:nth-child(5) input').checked,
document.querySelector('.container-fluid p:nth-child(6) input').checked,
document.querySelector('.container-fluid p:nth-child(7) input').checked
];
})
.end()
.then((value) => {
assert.equal(value, [false, false, false, true]);
});
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment