瀏覽代碼

Add test to NodeJS module screenshot feature

Gaël Métais 10 年之前
父節點
當前提交
9b9e65abd4
共有 1 個文件被更改,包括 22 次插入0 次删除
  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 sinonChai           = require('sinon-chai');
 var should              = chai.should();
+var path                = require('path');
+var fs                  = require('fs');
 var ylt                 = require('../../lib/index');
 
 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);
+            });
+    });
+
 });