浏览代码

Test that console.log is never called

Gaël Métais 10 年之前
父节点
当前提交
35aed5fb55
共有 2 个文件被更改,包括 14 次插入2 次删除
  1. 3 1
      package.json
  2. 11 1
      test/api/yellowlabtoolsTest.js

+ 3 - 1
package.json

@@ -32,7 +32,9 @@
     "matchdep": "^0.3.0",
     "mocha": "^2.0.1",
     "phantomjs": "^1.9.10",
-    "q": "^1.1.2"
+    "q": "^1.1.2",
+    "sinon": "^1.12.1",
+    "sinon-chai": "^2.6.0"
   },
   "scripts": {
     "test": "grunt test"

+ 11 - 1
test/api/yellowlabtoolsTest.js

@@ -1,6 +1,11 @@
-var should              = require('chai').should();
+var chai                = require('chai');
+var sinon               = require('sinon');
+var sinonChai           = require('sinon-chai');
+var should              = chai.should();
 var YellowLabTools      = require('../../lib/yellowlabtools.js');
 
+chai.use(sinonChai);
+
 
 describe('yellowlabtools', function() {
 
@@ -28,6 +33,9 @@ describe('yellowlabtools', function() {
     it('succeeds on simple-page.html', function(done) {
         this.timeout(15000);
 
+        // Check if console.log is called
+        sinon.spy(console, 'log')
+
         var url = 'http://localhost:8388/simple-page.html';
 
         var ylt = new YellowLabTools(url)
@@ -67,6 +75,8 @@ describe('yellowlabtools', function() {
                     "offenders": ["body > h1[1]"]
                 });
 
+                console.log.should.not.have.been.called;
+
                 done();
             }).fail(function(err) {
                 done(err);