From cbf931d55eda48c1c520e093cd310035a0e712b8 Mon Sep 17 00:00:00 2001 From: andy jiang Date: Tue, 30 Sep 2014 16:23:21 +0000 Subject: [PATCH] added a test for goBack() --- .DS_Store | Bin 6148 -> 6148 bytes lib/actions.js | 3 ++- test/index.js | 36 ++++++++++++++++++++++-------------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.DS_Store b/.DS_Store index 63085fcdb031daa385bb71d34fd41e37d35ce503..70e83e5202b61ee1a996811221a4a35b213d0e22 100644 GIT binary patch delta 72 zcmZoMXfc@J&&aVcU^gQp$7CL+!`gWa`3xxxsSNQ9xnNc)Lk^Hv?3t6FoRpKF#K6EH Wz`(#51f*wdKE%Y!x|yBhFFydR_Yxcc delta 30 mcmZoMXfc@J&&a+pU^gQp`(z%b!;9IOStmAFY-Z>9%MSpL%LzgN diff --git a/lib/actions.js b/lib/actions.js index e054558d..4280608d 100644 --- a/lib/actions.js +++ b/lib/actions.js @@ -41,9 +41,10 @@ exports.goto = function(url, done) { * */ -exports.goBack = function() { +exports.goBack = function(done) { debug('.goBack()'); this.page.goBack(); + done(); }; /** diff --git a/test/index.js b/test/index.js index c9a10fa3..cb869729 100644 --- a/test/index.js +++ b/test/index.js @@ -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/') @@ -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) { @@ -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); })