forked from juliangruber/capture-screenshot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
60 lines (54 loc) · 1.26 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var test = require('tape');
var Screenshot = require('./');
var http = require('http');
var server = http.createServer(function(req, res) {
res.end('ohai!');
}).listen(function() {
var url = 'http://localhost:' + server.address().port;
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('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();
});
test('obj', function(t) {
var s = Screenshot(url, {
width: 1024,
height: 768,
timeout: 100,
format: 'jpeg',
url: 'trololo'
});
t.equal(s._width, 1024);
t.equal(s._height, 768);
t.equal(s._timeout, 100);
t.equal(s._format, 'JPG');
t.equal(s.url, url);
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();
});
});
});