Fix tests
This commit is contained in:
@@ -13,16 +13,19 @@ describe('phantomasWrapper', function() {
|
||||
this.timeout(15000);
|
||||
|
||||
phantomasWrapper.execute({
|
||||
url: url,
|
||||
options: {}
|
||||
}).then(function(json) {
|
||||
json.should.be.an('object');
|
||||
json.should.have.a.property('generator');
|
||||
json.generator.should.contain('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('array').not.empty;
|
||||
params: {
|
||||
url: url,
|
||||
options: {}
|
||||
}
|
||||
}).then(function(data) {
|
||||
|
||||
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;
|
||||
data.offenders.should.have.a.property('javascriptExecutionTree').that.is.a('array').not.empty;
|
||||
|
||||
done();
|
||||
}).fail(function(err) {
|
||||
@@ -36,9 +39,11 @@ describe('phantomasWrapper', function() {
|
||||
this.timeout(15000);
|
||||
|
||||
phantomasWrapper.execute({
|
||||
url: url,
|
||||
options: {}
|
||||
}).then(function(json) {
|
||||
params: {
|
||||
url: url,
|
||||
options: {}
|
||||
}
|
||||
}).then(function(data) {
|
||||
|
||||
done('Error: unwanted success');
|
||||
|
||||
@@ -56,19 +61,21 @@ describe('phantomasWrapper', function() {
|
||||
|
||||
this.timeout(5000);
|
||||
phantomasWrapper.execute({
|
||||
url: url,
|
||||
options: {
|
||||
timeout: 1
|
||||
params: {
|
||||
url: url,
|
||||
options: {
|
||||
timeout: 1
|
||||
}
|
||||
}
|
||||
}).then(function(json) {
|
||||
}).then(function(data) {
|
||||
|
||||
json.should.be.an('object');
|
||||
json.should.have.a.property('generator');
|
||||
json.generator.should.contain('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('array').not.empty;
|
||||
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;
|
||||
data.offenders.should.have.a.property('javascriptExecutionTree').that.is.a('array').not.empty;
|
||||
|
||||
done();
|
||||
}).fail(function(err) {
|
||||
|
||||
@@ -7,24 +7,12 @@ describe('rulesChecker', function() {
|
||||
rulesChecker.should.have.property('check').that.is.a('function');
|
||||
});
|
||||
|
||||
it('should produce a nice rules object', function(done) {
|
||||
it('should produce a nice rules object', function() {
|
||||
var data = require('../fixtures/rulesCheckerInput.json');
|
||||
var policies = require('../fixtures/rulesCheckerPolicies.json');
|
||||
var expected = require('../fixtures/rulesCheckerOutput.json');
|
||||
|
||||
var checker = rulesChecker.check(data, policies);
|
||||
|
||||
checker.then(function(results) {
|
||||
try {
|
||||
results.should.deep.equals(expected);
|
||||
done();
|
||||
} catch(e) {
|
||||
done(e);
|
||||
}
|
||||
});
|
||||
|
||||
checker.fail(function(err) {
|
||||
done(err);
|
||||
});
|
||||
var results = rulesChecker.check(data, policies);
|
||||
results.should.deep.equals(expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,16 +32,40 @@ describe('yellowlabtools', function() {
|
||||
|
||||
var ylt = new YellowLabTools(url)
|
||||
.then(function(data) {
|
||||
data.should.be.an('object');
|
||||
data.should.have.a.property('url').that.equals(url);
|
||||
|
||||
data.should.have.a.property('metrics').that.is.an('object');
|
||||
data.metrics.should.have.a.property('requests').that.equals(1);
|
||||
|
||||
data.should.have.a.property('offenders').that.is.an('object');
|
||||
data.offenders.should.have.a.property('DOMelementMaxDepth');
|
||||
data.offenders.DOMelementMaxDepth.should.have.length(1);
|
||||
data.offenders.DOMelementMaxDepth[0].should.equal('body > h1[1]');
|
||||
data.should.be.an('object');
|
||||
data.toolsResults.should.be.an('object');
|
||||
|
||||
// Test Phantomas
|
||||
data.toolsResults.phantomas.should.be.an('object');
|
||||
data.toolsResults.phantomas.should.have.a.property('url').that.equals(url);
|
||||
data.toolsResults.phantomas.should.have.a.property('metrics').that.is.an('object');
|
||||
data.toolsResults.phantomas.metrics.should.have.a.property('requests').that.equals(1);
|
||||
data.toolsResults.phantomas.should.have.a.property('offenders').that.is.an('object');
|
||||
data.toolsResults.phantomas.offenders.should.have.a.property('DOMelementMaxDepth');
|
||||
data.toolsResults.phantomas.offenders.DOMelementMaxDepth.should.have.length(1);
|
||||
data.toolsResults.phantomas.offenders.DOMelementMaxDepth[0].should.equal('body > h1[1]');
|
||||
|
||||
// Test rules
|
||||
data.should.have.a.property('rules').that.is.an('object');
|
||||
|
||||
data.rules.should.have.a.property('DOMelementMaxDepth').that.is.an('object');
|
||||
data.rules.DOMelementMaxDepth.should.deep.equal({
|
||||
policy: {
|
||||
"tool": "phantomas",
|
||||
"label": "DOM max depth",
|
||||
"message": "<p>A deep DOM makes the CSS matching with DOM elements difficult.</p><p>It also slows down Javascript modifications to the DOM because changing the dimensions of an element makes the browser re-calculate the dimensions of it's parents. Same thing for Javascript events, that bubble up to the document root.</p>",
|
||||
"isOkThreshold": 10,
|
||||
"isBadThreshold": 20,
|
||||
"isAbnormalThreshold": 30
|
||||
},
|
||||
"value": 1,
|
||||
"bad": false,
|
||||
"abnormal": false,
|
||||
"score": 100,
|
||||
"abnormalityScore": 0,
|
||||
"offenders": ["body > h1[1]"]
|
||||
});
|
||||
|
||||
done();
|
||||
}).fail(function(err) {
|
||||
|
||||
Reference in New Issue
Block a user