yellowlabtoolsTest.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. var should = require('chai').should();
  2. var YellowLabTools = require('../../lib/yellowlabtools.js');
  3. describe('yellowlabtools', function() {
  4. it('returns a promise', function() {
  5. var ylt = new YellowLabTools();
  6. ylt.should.have.property('then').that.is.a('function');
  7. ylt.should.have.property('fail').that.is.a('function');
  8. });
  9. it('fails an undefined url', function(done) {
  10. var ylt = new YellowLabTools().fail(function(err) {
  11. err.should.be.a('string').that.equals('URL missing');
  12. done();
  13. });
  14. });
  15. it('fails with an empty url string', function(done) {
  16. var ylt = new YellowLabTools('').fail(function(err) {
  17. err.should.be.a('string').that.equals('URL missing');
  18. done();
  19. });
  20. });
  21. it('succeeds on simple-page.html', function(done) {
  22. this.timeout(15000);
  23. var url = 'http://localhost:8388/simple-page.html';
  24. var ylt = new YellowLabTools(url)
  25. .then(function(data) {
  26. data.should.be.an('object');
  27. data.should.have.a.property('url').that.equals(url);
  28. data.should.have.a.property('metrics').that.is.an('object');
  29. data.metrics.should.have.a.property('requests').that.equals(1);
  30. data.should.have.a.property('offenders').that.is.an('object');
  31. data.offenders.should.have.a.property('DOMelementMaxDepth');
  32. data.offenders.DOMelementMaxDepth.should.have.length(1);
  33. data.offenders.DOMelementMaxDepth[0].should.equal('body > h1[1]');
  34. done();
  35. }).fail(function(err) {
  36. done(err);
  37. });
  38. });
  39. });