[Groonga-commit] droonga/express-droonga at 60231e1 [master] Test without nodemock

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Mar 20 15:48:34 JST 2014


YUKI Hiroshi	2014-03-20 15:48:34 +0900 (Thu, 20 Mar 2014)

  New Revision: 60231e196386668aeca106614038b0c019cb5540
  https://github.com/droonga/express-droonga/commit/60231e196386668aeca106614038b0c019cb5540

  Message:
    Test without nodemock

  Modified files:
    test/response-cache/entry.test.js

  Modified: test/response-cache/entry.test.js (+30 -7)
===================================================================
--- test/response-cache/entry.test.js    2014-03-20 15:33:42 +0900 (e7aa3b5)
+++ test/response-cache/entry.test.js    2014-03-20 15:48:34 +0900 (f606237)
@@ -1,5 +1,4 @@
 var assert = require('chai').assert;
-var nodemock = require('nodemock');
 
 var Entry = require('../../lib/response-cache/entry');
 
@@ -23,15 +22,39 @@ suite('Response Cache Entry', function() {
     });
   });
 
-  test('store', function() {
-    var ttl = 10;
-    var value = true;
-    var mockedStorage = nodemock.mock('set').takes('key', { status: 200, headers: {}, body: [] }, ttl);
+  function createStubStorage() {
+    return {
+      'set': function() {
+        this.args.push(Array.prototype.slice.call(arguments, 0));
+      },
+      args: []
+    };
+  };
 
-    var entry = new Entry('key', ttl, mockedStorage);
+  test('store', function() {
+    var storage = createStubStorage();
+    var entry = new Entry('key', 10, storage);
     entry.data.status = 200;
     entry.store();
-    mockedStorage.assertThrows();
+    assert.deepEqual(storage.args, [['key', entry.data, 10]]);
+  });
+
+  suite('end', function() {
+    test('success', function() {
+      var storage = createStubStorage();
+      var entry = new Entry('key', 10, storage);
+      entry.data.status = 200;
+      entry.store();
+      assert.deepEqual(storage.args, [['key', entry.data, 10]]);
+    });
+
+    test('error', function() {
+      var storage = createStubStorage();
+      var entry = new Entry('key', 10, storage);
+      entry.data.status = 400;
+      entry.store();
+      assert.deepEqual(storage.args, []);
+    });
   });
 });
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index