-
-
Notifications
You must be signed in to change notification settings - Fork 125
Expand file tree
/
Copy pathphantomasWrapperTest.js
More file actions
63 lines (50 loc) · 1.73 KB
/
Copy pathphantomasWrapperTest.js
File metadata and controls
63 lines (50 loc) · 1.73 KB
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
60
61
62
63
var should = require('chai').should();
var phantomasWrapper = require('../../lib/tools/phantomas/phantomasWrapper');
describe('phantomasWrapper', function() {
it('should have a method execute', function() {
phantomasWrapper.should.have.property('execute').that.is.a('function');
});
it('should execute', function(done) {
var url = 'http://localhost:8388/simple-page.html';
this.timeout(15000);
phantomasWrapper.execute({
params: {
url: url,
options: {}
}
}).then(function(data) {
/*jshint -W030 */
data.should.be.an('object');
data.should.have.a.property('generator');
data.generator.should.contain('phantomas');
data.should.have.a.property('url').that.equals(url);
data.should.have.a.property('metrics').that.is.an('object').not.empty;
data.should.have.a.property('offenders').that.is.an('object').not.empty;
done();
}).fail(function(err) {
done(err);
});
});
it('should fail when page cannot be fetched', function(done) {
var url = 'http://localhost:8389/not-existing.html';
this.timeout(15000);
phantomasWrapper.execute({
params: {
url: url,
options: {
device: 'desktop'
}
}
}).then(function(data) {
done('Error: unwanted success');
}).fail(function(err) {
try {
console.log(err);
should.exist(err);
done();
} catch(error) {
done(error);
}
});
});
});