From 2ba4410a270edc38b7897028416bf6755da483b9 Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:54:14 +0000 Subject: [PATCH 01/18] Update clone-object.js --- test/clone-object.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/clone-object.js b/test/clone-object.js index 86ec647..89cb012 100644 --- a/test/clone-object.js +++ b/test/clone-object.js @@ -1,7 +1,7 @@ describe('clone object', function () { it('should clone an object', function () { var expected = {name: 'Ahmed', age: 27, skills: ['cycling', 'walking', 'eating']}, - obj = {}; + obj = JSON.parse(JSON.stringify(expected)); expect(obj).toEqual(expected); expect(obj).not.toBe(expected); From 9592d2690f5bd12c414fb9188b56f778071b23a0 Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:55:22 +0000 Subject: [PATCH 02/18] Update flatten-array.js --- test/flatten-array.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/flatten-array.js b/test/flatten-array.js index c7f0632..f62e35a 100644 --- a/test/flatten-array.js +++ b/test/flatten-array.js @@ -2,7 +2,9 @@ describe('flatten array', function () { it('should flatten an array', function () { var arr = [1, 2, [1, 2, [3, 4, 5, [1]]], 2, [2]], expected = [1, 1, 1, 2, 2, 2, 2, 3, 4, 5]; + + arr = arr.flat(Infinity).sort(function(a, b){return a-b}); expect(arr).toEqual(expected); }); -}); \ No newline at end of file +}); From 0db2143a05b6d1892d48fcfabdca1e24f7b03646 Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:24:48 +0000 Subject: [PATCH 03/18] Update scoping.js --- test/scoping.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/scoping.js b/test/scoping.js index 557c54a..5b46673 100644 --- a/test/scoping.js +++ b/test/scoping.js @@ -15,10 +15,11 @@ describe('scoping', function () { return this.foo; }; +// explicitely setting the 'this' value Module.prototype.req = function() { - return request(this.method); + return request(this.method.bind(this)); }; expect(mod.req()).toBe('bar'); }); -}); \ No newline at end of file +}); From fdc2e9bb10f64c48289394a5819ab7d07ec179aa Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:25:30 +0000 Subject: [PATCH 04/18] Update clone-object.js --- test/clone-object.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/clone-object.js b/test/clone-object.js index 89cb012..497f46f 100644 --- a/test/clone-object.js +++ b/test/clone-object.js @@ -1,6 +1,7 @@ describe('clone object', function () { it('should clone an object', function () { var expected = {name: 'Ahmed', age: 27, skills: ['cycling', 'walking', 'eating']}, +// efficient one line to clone objects obj = JSON.parse(JSON.stringify(expected)); expect(obj).toEqual(expected); From 077709a863056692f4522efe9fceffb723ae877b Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:26:24 +0000 Subject: [PATCH 05/18] Update flatten-array.js --- test/flatten-array.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/flatten-array.js b/test/flatten-array.js index f62e35a..99cfdd8 100644 --- a/test/flatten-array.js +++ b/test/flatten-array.js @@ -3,6 +3,7 @@ describe('flatten array', function () { var arr = [1, 2, [1, 2, [3, 4, 5, [1]]], 2, [2]], expected = [1, 1, 1, 2, 2, 2, 2, 3, 4, 5]; +// Using inbuilt flatten and sort functionality in a neat one liner arr = arr.flat(Infinity).sort(function(a, b){return a-b}); expect(arr).toEqual(expected); From 8a105dea3deb6e5d09cd74de91885e38e94fceb0 Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:52:30 +0000 Subject: [PATCH 06/18] Update clone-object.js --- test/clone-object.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/clone-object.js b/test/clone-object.js index 497f46f..17e8ffd 100644 --- a/test/clone-object.js +++ b/test/clone-object.js @@ -1,7 +1,7 @@ describe('clone object', function () { it('should clone an object', function () { var expected = {name: 'Ahmed', age: 27, skills: ['cycling', 'walking', 'eating']}, -// efficient one line to clone objects +// efficient one line to clone objects. obj = JSON.parse(JSON.stringify(expected)); expect(obj).toEqual(expected); From 619a88d1d4e17d4a6116f440de1743dc3e26c94a Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 15:04:27 +0000 Subject: [PATCH 07/18] Update .travis.yml --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7caf3cd..a72bc84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,8 @@ language: node_js node_js: - "node" - "iojs" +services: + - "xvfb" before_script: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start From 51b835145f0a0c2da583e4793fc0b40f20b118c8 Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 15:05:55 +0000 Subject: [PATCH 08/18] Update package.json --- package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7d46b91..031cc6f 100644 --- a/package.json +++ b/package.json @@ -26,9 +26,10 @@ }, "homepage": "https://github.com/ahmednuaman/javascript-tests", "dependencies": { - "karma": "^0.12.32", - "karma-jasmine": "^0.3.5", - "karma-phantomjs-launcher": "^0.1.4" + "jasmine-core": "2.99.0", + "karma": "0.13.22", + "karma-jasmine": "0.3.8", + "karma-phantomjs-launcher": "1.0.4" }, "devDependencies": { "karma-chrome-launcher": "^0.1.12", From 90c9c9d367fa84241f3e9da7ca80c314aecc7c61 Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 15:11:00 +0000 Subject: [PATCH 09/18] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a72bc84..349843b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ node_js: - "node" - "iojs" services: - - "xvfb" + - xvfb before_script: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start From 051f63e187d331ef3481c0183d2a958f8af9f40d Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 15:14:23 +0000 Subject: [PATCH 10/18] Update .travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 349843b..266449a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,3 @@ services: - xvfb before_script: - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start From 28a814cb885a31e8a475fef647ed3ddd93f0f9ff Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 15:16:28 +0000 Subject: [PATCH 11/18] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 266449a..8c1c462 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,6 @@ node_js: - "node" - "iojs" services: - - xvfb + - "xvfb" before_script: - export DISPLAY=:99.0 From ebb88cf8aad55766b2fd5da378df3e38f3e69993 Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 15:26:44 +0000 Subject: [PATCH 12/18] Update package.json --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 031cc6f..74202d4 100644 --- a/package.json +++ b/package.json @@ -26,9 +26,9 @@ }, "homepage": "https://github.com/ahmednuaman/javascript-tests", "dependencies": { - "jasmine-core": "2.99.0", - "karma": "0.13.22", - "karma-jasmine": "0.3.8", + "jasmine-core": "2.3.4", + "karma": "^0.13.22", + "karma-jasmine": "0.3.5", "karma-phantomjs-launcher": "1.0.4" }, "devDependencies": { From eb22ce40db7482cc3317387390a8e3dcd617bb99 Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 15:33:28 +0000 Subject: [PATCH 13/18] Update flatten-array.js --- test/flatten-array.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/flatten-array.js b/test/flatten-array.js index 99cfdd8..75641fe 100644 --- a/test/flatten-array.js +++ b/test/flatten-array.js @@ -4,7 +4,7 @@ describe('flatten array', function () { expected = [1, 1, 1, 2, 2, 2, 2, 3, 4, 5]; // Using inbuilt flatten and sort functionality in a neat one liner - arr = arr.flat(Infinity).sort(function(a, b){return a-b}); + arr = arr.flat('Infinity').sort(function(a, b){return a-b}); expect(arr).toEqual(expected); }); From 2086dcd930653681d5296c39732dcedb0ee9c911 Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 15:38:07 +0000 Subject: [PATCH 14/18] Update flatten-array.js --- test/flatten-array.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/flatten-array.js b/test/flatten-array.js index 75641fe..cf87047 100644 --- a/test/flatten-array.js +++ b/test/flatten-array.js @@ -4,7 +4,10 @@ describe('flatten array', function () { expected = [1, 1, 1, 2, 2, 2, 2, 3, 4, 5]; // Using inbuilt flatten and sort functionality in a neat one liner - arr = arr.flat('Infinity').sort(function(a, b){return a-b}); + const arrAsString = arr.toString(); + const flatArr = arrAsString.split(',').map(Number); + + arr = flatArr.sort(); expect(arr).toEqual(expected); }); From 20473709a8eac1eabff6801c47aad1470c7f62c0 Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 15:53:03 +0000 Subject: [PATCH 15/18] Update flatten-array.js --- test/flatten-array.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/flatten-array.js b/test/flatten-array.js index cf87047..0fb82ef 100644 --- a/test/flatten-array.js +++ b/test/flatten-array.js @@ -3,9 +3,9 @@ describe('flatten array', function () { var arr = [1, 2, [1, 2, [3, 4, 5, [1]]], 2, [2]], expected = [1, 1, 1, 2, 2, 2, 2, 3, 4, 5]; -// Using inbuilt flatten and sort functionality in a neat one liner - const arrAsString = arr.toString(); - const flatArr = arrAsString.split(',').map(Number); +// re-write to work with travis, converting the array to a string array and then mapping it as number array, then finally sorting it into the correct order + let stringArr = arr.toString(); + let flattenedArr = arrAsString.split(',').map(Number); arr = flatArr.sort(); From 5fccde1be7215ea2fc22635a6f83500ea864429a Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 15:55:07 +0000 Subject: [PATCH 16/18] Update flatten-array.js --- test/flatten-array.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/flatten-array.js b/test/flatten-array.js index 0fb82ef..ff64d3e 100644 --- a/test/flatten-array.js +++ b/test/flatten-array.js @@ -7,7 +7,7 @@ describe('flatten array', function () { let stringArr = arr.toString(); let flattenedArr = arrAsString.split(',').map(Number); - arr = flatArr.sort(); + arr = flattenedArr.sort(); expect(arr).toEqual(expected); }); From 4a2f80efa60a470a59e914fb2f78aa19b7b8ab04 Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 15:57:40 +0000 Subject: [PATCH 17/18] Update flatten-array.js --- test/flatten-array.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/flatten-array.js b/test/flatten-array.js index ff64d3e..ca72c8d 100644 --- a/test/flatten-array.js +++ b/test/flatten-array.js @@ -5,7 +5,7 @@ describe('flatten array', function () { // re-write to work with travis, converting the array to a string array and then mapping it as number array, then finally sorting it into the correct order let stringArr = arr.toString(); - let flattenedArr = arrAsString.split(',').map(Number); + let flattenedArr = stringArr.split(',').map(Number); arr = flattenedArr.sort(); From f8c5d907268a926875c45c17c7f9d00b2dadbcb0 Mon Sep 17 00:00:00 2001 From: BenCollins97 <42169342+BenCollins97@users.noreply.github.com> Date: Wed, 18 Mar 2020 16:01:27 +0000 Subject: [PATCH 18/18] Update flatten-array.js --- test/flatten-array.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/flatten-array.js b/test/flatten-array.js index ca72c8d..3746700 100644 --- a/test/flatten-array.js +++ b/test/flatten-array.js @@ -4,8 +4,8 @@ describe('flatten array', function () { expected = [1, 1, 1, 2, 2, 2, 2, 3, 4, 5]; // re-write to work with travis, converting the array to a string array and then mapping it as number array, then finally sorting it into the correct order - let stringArr = arr.toString(); - let flattenedArr = stringArr.split(',').map(Number); + const stringArr = arr.toString(); + const flattenedArr = stringArr.split(',').map(Number); arr = flattenedArr.sort();