Skip to content

Commit

Permalink
added a test for goBack()
Browse files Browse the repository at this point in the history
  • Loading branch information
lambtron committed Sep 30, 2014
1 parent e0fd603 commit cbf931d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
Binary file modified .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion lib/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ exports.goto = function(url, done) {
*
*/

exports.goBack = function() {
exports.goBack = function(done) {
debug('.goBack()');
this.page.goBack();
done();
};

/**
Expand Down
36 changes: 22 additions & 14 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ describe('Nightmare', function(){

describe('navigation', function(){

it('should click on a link and then go back', function(done) {
new Nightmare()
.goto('https://segment.io/')
.click('a[href="/docs"]')
.goBack()
.run(done);
});

it('should goto wikipedia.org', function(done) {
new Nightmare()
.goto('http://www.wikipedia.org/')
Expand Down Expand Up @@ -57,19 +65,19 @@ describe('Nightmare', function(){
});

it('should type and click', function(done) {
nightmare
.type('.input-query', 'github nightmare')
.click('.searchsubmit')
.wait()
.evaluate(function () {
return document.title;
}, function (title) {
title.should.equal('github nightmare - Yahoo Search Results');
})
.run(function (err, nightmare) {
nightmare.should.be.ok;
done();
});
nightmare
.type('.input-query', 'github nightmare')
.click('.searchsubmit')
.wait()
.evaluate(function () {
return document.title;
}, function (title) {
title.should.equal('github nightmare - Yahoo Search Results');
})
.run(function (err, nightmare) {
nightmare.should.be.ok;
done();
});
});

it('should take a screenshot', function(done) {
Expand Down Expand Up @@ -204,7 +212,7 @@ describe('Nightmare', function(){
.goto('http://yahoo.com')
.evaluate(function () {
window.testQueue = [];
window.testQueue.push(1);
window.testQueue.push(1);
}, function () {
queue.push(1);
})
Expand Down

2 comments on commit cbf931d

@mdaniel
Copy link

@mdaniel mdaniel commented on cbf931d Oct 6, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't commit .DS_Store files to git

Those make a great candidate for inclusion in .gitignore

@lambtron
Copy link
Contributor Author

@lambtron lambtron commented on cbf931d Oct 6, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.