First server tests

This commit is contained in:
Gaël Métais
2014-09-03 09:06:35 +02:00
parent 3b365772d2
commit 1d66d9658c
6 changed files with 125 additions and 3 deletions
+52
View File
@@ -0,0 +1,52 @@
var should = require('chai').should();
var phantomasWrapper = require('../../app/lib/phantomasWrapper.js');
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://www.google.fr';
this.timeout(15000);
phantomasWrapper.execute({
url: url,
testId: '123abc',
options:{
}
}, function(err, json, results) {
should.not.exist(err);
json.should.be.an('object');
json.should.have.a.property('generator').that.contains('phantomas');
json.should.have.a.property('url').that.equals(url);
json.should.have.a.property('metrics').that.is.an('object').not.empty();
json.should.have.a.property('offenders').that.is.an('object').not.empty();
json.offenders.should.have.a.property('javascriptExecutionTree').that.is.a('string');
done();
});
});
it('should fail with error 254', function(done) {
var url = 'http://www.not.existing';
this.timeout(15000);
phantomasWrapper.execute({
url: url,
testId: '123abc',
options:{
}
}, function(err, json, results) {
should.exist(err);
err.should.equal(254);
should.not.exist(json);
done();
});
});
});