From dcda142655619b92ba2f3cc8b904d473ad426e29 Mon Sep 17 00:00:00 2001 From: Pier Paolo Ramon Date: Wed, 5 Oct 2011 14:14:51 +0200 Subject: [PATCH] Tests for _.init --- test/arrays.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/arrays.js b/test/arrays.js index 02e282b8a..3d5cc3327 100644 --- a/test/arrays.js +++ b/test/arrays.js @@ -24,6 +24,15 @@ $(document).ready(function() { equals(_.flatten(result).join(','), '2,3,2,3', 'works well with _.map'); }); + test("arrays: init", function() { + equals(_.init([1,2,3,4,5]).join(", "), "1, 2, 3, 4", 'working init()'); + equals(_.init([1,2,3,4],2).join(", "), "1, 2", 'init can take an index'); + var result = (function(){ return _(arguments).init(); })(1, 2, 3, 4); + equals(result.join(", "), "1, 2, 3", 'init works on arguments object'); + result = _.map([[1,2,3],[1,2,3]], _.init); + equals(_.flatten(result).join(','), '1,2,1,2', 'init works with _.map'); + }); + test("arrays: last", function() { equals(_.last([1,2,3]), 3, 'can pull out the last element of an array'); equals(_.last([1,2,3], 0).join(', '), "", 'can pass an index to last');