From 6b922d02ea4578a60cbb099c09d5a33f7f0f1885 Mon Sep 17 00:00:00 2001 From: Barney Carroll Date: Wed, 31 Aug 2016 11:51:15 +0100 Subject: [PATCH 1/2] Spies reflect wrapped function's name & length --- ospec/ospec.js | 5 +++++ ospec/tests/test-ospec.js | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ospec/ospec.js b/ospec/ospec.js index af0484ef..50b9899e 100644 --- a/ospec/ospec.js +++ b/ospec/ospec.js @@ -27,6 +27,11 @@ module.exports = new function init() { if (fn) return fn.apply(this, arguments) } + if (fn) + Object.defineProperties(spy, { + length: {value: fn.length}, + name: {value: fn.name} + }) spy.args = [] spy.callCount = 0 return spy diff --git a/ospec/tests/test-ospec.js b/ospec/tests/test-ospec.js index fc40c17f..38ce0438 100644 --- a/ospec/tests/test-ospec.js +++ b/ospec/tests/test-ospec.js @@ -60,6 +60,8 @@ o.spec("ospec", function() { var output = spy.call(state, {children: children}) + o(spy.length).equals(1) + o(spy.name).equals('view') o(spy.callCount).equals(1) o(spy.args.length).equals(1) o(spy.args[0]).deepEquals({children: children}) From b8e3dcfbe4d01841faadda9ff4db93b29b47b6fe Mon Sep 17 00:00:00 2001 From: Barney Carroll Date: Wed, 31 Aug 2016 11:54:21 +0100 Subject: [PATCH 2/2] Code style fix for 6b922d0: substitute double quotes --- ospec/tests/test-ospec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ospec/tests/test-ospec.js b/ospec/tests/test-ospec.js index 38ce0438..3b1dd440 100644 --- a/ospec/tests/test-ospec.js +++ b/ospec/tests/test-ospec.js @@ -61,7 +61,7 @@ o.spec("ospec", function() { var output = spy.call(state, {children: children}) o(spy.length).equals(1) - o(spy.name).equals('view') + o(spy.name).equals("view") o(spy.callCount).equals(1) o(spy.args.length).equals(1) o(spy.args[0]).deepEquals({children: children})