phantomasWrapperTest.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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(15000);
  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').that.contains('phantomas');
  19. json.should.have.a.property('url').that.equals(url);
  20. json.should.have.a.property('metrics').that.is.an('object').not.empty();
  21. json.should.have.a.property('offenders').that.is.an('object').not.empty();
  22. json.offenders.should.have.a.property('javascriptExecutionTree').that.is.a('string');
  23. done();
  24. });
  25. });
  26. it('should fail with error 254', function(done) {
  27. var url = 'http://www.not.existing';
  28. this.timeout(15000);
  29. phantomasWrapper.execute({
  30. url: url,
  31. testId: '123abc',
  32. options:{
  33. }
  34. }, function(err, json, results) {
  35. should.exist(err);
  36. err.should.equal(254);
  37. should.not.exist(json);
  38. done();
  39. });
  40. });
  41. });