Skip to content

Instantly share code, notes, and snippets.

@fzaninotto
Last active December 11, 2017 15:54
Show Gist options
  • Save fzaninotto/43f420d082d0884c94d9 to your computer and use it in GitHub Desktop.
Save fzaninotto/43f420d082d0884c94d9 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);
});
@robert-wallis
Copy link

The red highlighting is because the line ends with two single quote marks: ' '

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment