Browse Source

Add test to NodeJS module screenshot feature

Gaël Métais 10 years ago
parent
commit
9b9e65abd4
1 changed files with 22 additions and 0 deletions
  1. 22 0
      test/core/indexTest.js

+ 22 - 0
test/core/indexTest.js

@@ -2,6 +2,8 @@ var chai                = require('chai');
 var sinon               = require('sinon');
 var sinon               = require('sinon');
 var sinonChai           = require('sinon-chai');
 var sinonChai           = require('sinon-chai');
 var should              = chai.should();
 var should              = chai.should();
+var path                = require('path');
+var fs                  = require('fs');
 var ylt                 = require('../../lib/index');
 var ylt                 = require('../../lib/index');
 
 
 chai.use(sinonChai);
 chai.use(sinonChai);
@@ -99,4 +101,24 @@ describe('index.js', function() {
             });
             });
     });
     });
 
 
+    it('should take a screenshot', function(done) {
+        this.timeout(15000);
+
+        var url = 'http://localhost:8388/simple-page.html';
+        var screenshotPath = path.join(__dirname, '../../.tmp/indexTestScreenshot.png');
+
+        ylt(url, {screenshot: screenshotPath})
+            .then(function(data) {
+
+                data.params.options.should.have.a.property('screenshot').that.equals(screenshotPath);
+                data.should.not.have.a.property('screenshotUrl');
+
+                fs.existsSync(screenshotPath).should.equal(true);
+
+                done();
+            }).fail(function(err) {
+                done(err);
+            });
+    });
+
 });
 });