From c72171d1dada92c0f8843872d42b5a3c0456e350 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 10 Jun 2014 09:50:10 -0700 Subject: [PATCH] Add `_.once` tests for memorized return values. --- test/test.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/test.js b/test/test.js index b1adc6540..670f5aa1b 100644 --- a/test/test.js +++ b/test/test.js @@ -6839,33 +6839,33 @@ QUnit.module('lodash.once'); (function() { - test('should execute `func` once', 1, function() { + test('should execute `func` once', 2, function() { var count = 0, - once = _.once(function() { count++; }); + once = _.once(function() { return ++count; }); once(); - once(); + strictEqual(once(), 1); strictEqual(count, 1); }); - test('should not set a `this` binding', 1, function() { - var once = _.once(function() { this.count++; }), + test('should not set a `this` binding', 2, function() { + var once = _.once(function() { return ++this.count; }), object = { 'count': 0, 'once': once }; object.once(); - object.once(); + strictEqual(object.once(), 1); strictEqual(object.count, 1); }); - test('should ignore recursive calls', 1, function() { + test('should ignore recursive calls', 2, function() { var count = 0; var once = _.once(function() { - count++; once(); + return ++count; }); - once(); + strictEqual(once(), 1); strictEqual(count, 1); });