forked from GoogleChromeLabs/psi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
40 lines (37 loc) · 928 Bytes
/
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
'use strict';
var fs = require('fs');
var assert = require('assert');
var insights = require('./index');
it('should throw if no valid URL is provided', function (done) {
insights({}
, function(err, data){
if(/Invalid url/.test(err)) {
return true;
}
done();
});
});
it('should return desktop results from PageSpeed Insights', function (done) {
insights({
url: 'http://html5rocks.com',
strategy: 'desktop',
threshold: 80
}, function(err, data){
assert(data.responseCode == 200);
assert(data.id == 'http://www.html5rocks.com/en/');
done();
});
});
it('should return mobile results from PageSpeed Insights', function (done) {
insights({
url: 'http://html5rocks.com',
locale: 'en_GB',
strategy: 'mobile',
threshold: 73
}, function(err, data){
assert(data.score == 73);
assert(data.responseCode == 200);
assert(data.id == 'http://www.html5rocks.com/en/');
done();
});
});