phantomasWrapperTest.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. var should = require('chai').should();
  2. var phantomasWrapper = require('../../app/lib/phantomasWrapper.js');
  3. describe('phantomasWrapper', function() {
  4. it('should have a method execute', function() {
  5. phantomasWrapper.should.have.property('execute').that.is.a('function');
  6. });
  7. it('should execute', function(done) {
  8. var url = 'http://www.google.fr/';
  9. this.timeout(20000);
  10. phantomasWrapper.execute({
  11. url: url,
  12. testId: '123abc',
  13. options:{
  14. }
  15. }, function(err, json, results) {
  16. should.not.exist(err);
  17. json.should.be.an('object');
  18. json.should.have.a.property('generator');
  19. json.generator.should.contain('phantomas');
  20. json.should.have.a.property('url').that.equals(url);
  21. json.should.have.a.property('metrics').that.is.an('object').not.empty;
  22. json.should.have.a.property('offenders').that.is.an('object').not.empty;
  23. json.offenders.should.have.a.property('javascriptExecutionTree').that.is.a('array').not.empty;
  24. done();
  25. });
  26. });
  27. it('should fail with error 254', function(done) {
  28. var url = 'http://www.not.existing';
  29. this.timeout(15000);
  30. phantomasWrapper.execute({
  31. url: url,
  32. testId: '123abc',
  33. options:{
  34. }
  35. }, function(err, json, results) {
  36. should.exist(err);
  37. err.should.equal(254);
  38. should.not.exist(json);
  39. done();
  40. });
  41. });
  42. });