From 5af9949a4c9143fa59fcddb88a76f2f5dd8a77f1 Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Uddin Date: Wed, 9 Jun 2021 15:48:07 +0400 Subject: [PATCH] Update test.js Test is added --- test.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test.js b/test.js index 378bc5a..24e5274 100644 --- a/test.js +++ b/test.js @@ -31,10 +31,14 @@ describe('last', function() { assert.strictEqual(last(['a', 'b', 'c', 'd', 'e', 'f'], 1), 'f'); }); - it('should the last n elements of the array:', function() { + it('should return the last n elements of the array:', function() { assert.deepEqual(last(['a', 'b', 'c', 'd', 'e', 'f'], 3), ['d', 'e', 'f']); }); + it('should not include undefined in the returned elements of the array:', function() { + assert.deepEqual(last(['a', 'b', 'c', 'd', 'e', 'f'], 7), ['a', 'b', 'c', 'd', 'e', 'f']); + }); + it('should return null if the array has no elements', function() { assert.strictEqual(last([]), null); assert.strictEqual(last([], 3), null);