Skip to content

Commit

Permalink
use local server for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Aug 26, 2013
1 parent 5817ead commit 40bb33a
Showing 1 changed file with 49 additions and 40 deletions.
89 changes: 49 additions & 40 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,58 @@
var test = require('tape');
var Screenshot = require('./');
var http = require('http');

test('screenshot', function(t) {
t.plan(3);
Screenshot('http://google.com')
.capture(function(err, pic) {
t.error(err);
t.ok(pic);
t.ok(Buffer.isBuffer(pic));
});
});
var server = http.createServer(function(req, res) {
res.end('ohai!');
}).listen(function() {
var url = 'http://localhost:' + server.address().port;

test('custom args', function(t) {
var s = Screenshot('http://google.com')
.width(1024)
.height(768)
.timeout(100)
.format('jpeg');
t.equal(s._width, 1024);
t.equal(s._height, 768);
t.equal(s._timeout, 100);
t.equal(s._format, 'JPG');
t.end();
});
test('screenshot', function(t) {
t.plan(3);
Screenshot(url)
.capture(function(err, pic) {
t.error(err);
t.ok(pic);
t.ok(Buffer.isBuffer(pic));
});
});

test('obj', function(t) {
var s = Screenshot('http://google.com', {
width: 1024,
height: 768,
timeout: 100,
format: 'jpeg'
test('custom args', function(t) {
var s = Screenshot(url)
.width(1024)
.height(768)
.timeout(100)
.format('jpeg');
t.equal(s._width, 1024);
t.equal(s._height, 768);
t.equal(s._timeout, 100);
t.equal(s._format, 'JPG');
t.end();
});
t.equal(s._width, 1024);
t.equal(s._height, 768);
t.equal(s._timeout, 100);
t.equal(s._format, 'JPG');
t.end();
});

test('generator', function(t) {
t.plan(3);
Screenshot('http://google.com')
.capture()(function(err, pic) {
t.error(err);
t.ok(pic);
t.ok(Buffer.isBuffer(pic));
test('obj', function(t) {
var s = Screenshot(url, {
width: 1024,
height: 768,
timeout: 100,
format: 'jpeg'
});
t.equal(s._width, 1024);
t.equal(s._height, 768);
t.equal(s._timeout, 100);
t.equal(s._format, 'JPG');
t.end();
});

test('generator', function(t) {
t.plan(3);
Screenshot(url)
.capture()(function(err, pic) {
t.error(err);
t.ok(pic);
t.ok(Buffer.isBuffer(pic));
server.close();
});
});
});

0 comments on commit 40bb33a

Please sign in to comment.