Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vukanac/190a339305313699cad9d3985cbbcf18 to your computer and use it in GitHub Desktop.
Save vukanac/190a339305313699cad9d3985cbbcf18 to your computer and use it in GitHub Desktop.
it('should refuse partial submissions', function(done) {
var browser = this.browser;
browser.fill('first_name', 'John');
browser.pressButton('Send').then(function() {
assert.ok(browser.success);
assert.equal(browser.text('h1'), 'Contact');
assert.equal(browser.text('div.alert'), 'Please fill in all the fields');
}).then(done, done);
});
it('should keep values on partial submissions', function(done) {
var browser = this.browser;
browser.fill('first_name', 'John');
browser.pressButton('Send').then(function() {
assert.equal(browser.field('first_name').value, 'John');
}).then(done, done);
});
it('should refuse invalid emails', function(done) {
var browser = this.browser;
browser.fill('first_name', 'John');
browser.fill('last_name', 'Doe');
browser.fill('email', 'incorrect email');
browser.fill('message', 'Lorem ipsum');
browser.pressButton('Send').then(function() {
assert.ok(browser.success);
assert.equal(browser.text('h1'), 'Contact');
assert.equal(browser.text('div.alert'), 'Please check the email address format');
}).then(done, done);
});
it('should accept complete submissions', function(done) {
var browser = this.browser;
browser.fill('first_name', 'John');
browser.fill('last_name', 'Doe');
browser.fill('email', '[email protected]');
browser.fill('message', 'Lorem ipsum');
browser.pressButton('Send').then(function() {
assert.ok(browser.success);
assert.equal(browser.text('h1'), 'Message Sent');
assert.equal(browser.text('p'), 'Thank you for your message. We\'ll answer you shortly.');
}).then(done, done);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment