From 29a03634991f5207c7e21f415323e654db431a7b Mon Sep 17 00:00:00 2001 From: Nathan Harrenstein Date: Tue, 18 Jul 2017 12:22:50 -0700 Subject: [PATCH 01/14] Set up project. --- lab-nathan/.eslintignore | 5 ++ lab-nathan/.eslintrc | 23 +++++++ lab-nathan/.gitignore | 136 +++++++++++++++++++++++++++++++++++++ lab-nathan/lib/fp.js | 0 lab-nathan/package.json | 17 +++++ lab-nathan/test/fp-test.js | 0 6 files changed, 181 insertions(+) create mode 100644 lab-nathan/.eslintignore create mode 100644 lab-nathan/.eslintrc create mode 100644 lab-nathan/.gitignore create mode 100644 lab-nathan/lib/fp.js create mode 100644 lab-nathan/package.json create mode 100644 lab-nathan/test/fp-test.js diff --git a/lab-nathan/.eslintignore b/lab-nathan/.eslintignore new file mode 100644 index 0000000..05b1cf3 --- /dev/null +++ b/lab-nathan/.eslintignore @@ -0,0 +1,5 @@ +**/node_modules/* +**/vendor/* +**/*.min.js +**/coverage/* +**/build/* diff --git a/lab-nathan/.eslintrc b/lab-nathan/.eslintrc new file mode 100644 index 0000000..c8dfef7 --- /dev/null +++ b/lab-nathan/.eslintrc @@ -0,0 +1,23 @@ +{ + "rules": { + "no-console": "off", + "indent": [ "error", 2 ], + "quotes": [ "error", "single" ], + "semi": ["error", "always"], + "linebreak-style": [ "error", "unix" ] + }, + "env": { + "es6": true, + "node": true, + "mocha": true, + "jasmine": true + }, + "parserOptions": { + "ecmaFeatures": { + "modules": true, + "experimentalObjectRestSpread": true, + "impliedStrict": true + } + }, + "extends": "eslint:recommended" +} diff --git a/lab-nathan/.gitignore b/lab-nathan/.gitignore new file mode 100644 index 0000000..345130c --- /dev/null +++ b/lab-nathan/.gitignore @@ -0,0 +1,136 @@ +# Created by https://www.gitignore.io/api/osx,vim,node,macos,windows + +### macOS ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + + +### OSX ### + +# Icon must end with two \r + +# Thumbnails + +# Files that might appear in the root of a volume + +# Directories potentially created on remote AFP share + +### Vim ### +# swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-v][a-z] +[._]sw[a-p] +# session +Session.vim +# temporary +.netrwhist +*~ +# auto-generated tag files +tags + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.gitignore.io/api/osx,vim,node,macos,windows diff --git a/lab-nathan/lib/fp.js b/lab-nathan/lib/fp.js new file mode 100644 index 0000000..e69de29 diff --git a/lab-nathan/package.json b/lab-nathan/package.json new file mode 100644 index 0000000..530d510 --- /dev/null +++ b/lab-nathan/package.json @@ -0,0 +1,17 @@ +{ + "name": "lab-nathan", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "lint": "eslint .", + "test": "mocha" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "chai": "^4.1.0", + "mocha": "^3.4.2" + } +} diff --git a/lab-nathan/test/fp-test.js b/lab-nathan/test/fp-test.js new file mode 100644 index 0000000..e69de29 From 2b88df51ccabc136d913c01b4b3f391fc4eaeaa3 Mon Sep 17 00:00:00 2001 From: Nathan Harrenstein Date: Tue, 18 Jul 2017 12:30:38 -0700 Subject: [PATCH 02/14] Adds test for map function. --- lab-nathan/test/fp-test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lab-nathan/test/fp-test.js b/lab-nathan/test/fp-test.js index e69de29..f48b2c9 100644 --- a/lab-nathan/test/fp-test.js +++ b/lab-nathan/test/fp-test.js @@ -0,0 +1,13 @@ +'use strict'; + +const fp = require('../lib/fp.js'); +const expect = require('chai').expect; + +describe('fp', function() { + describe('#map()', function() { + it('should return an array of doubled values.', function() { + let result = fp.map([1, 2, 3], num => num * 2); + expect(result).to.equal([2, 4, 6]); + }); + }); +}); \ No newline at end of file From 2d6af9df9e653dd594cd6e2180196b9e477459ad Mon Sep 17 00:00:00 2001 From: Nathan Harrenstein Date: Tue, 18 Jul 2017 12:32:31 -0700 Subject: [PATCH 03/14] Adds test for filter function --- lab-nathan/test/fp-test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lab-nathan/test/fp-test.js b/lab-nathan/test/fp-test.js index f48b2c9..3078821 100644 --- a/lab-nathan/test/fp-test.js +++ b/lab-nathan/test/fp-test.js @@ -10,4 +10,11 @@ describe('fp', function() { expect(result).to.equal([2, 4, 6]); }); }); + + describe('#filter()', function() { + it('should return 2.', function() { + let result = fp.filter([1, 2, 3], 2); + expect(result).to.equal([1, 3]); + }); + }); }); \ No newline at end of file From 7e796c4fd7f73aff34ed0ec3b4aeced24898ae57 Mon Sep 17 00:00:00 2001 From: Nathan Harrenstein Date: Tue, 18 Jul 2017 12:37:45 -0700 Subject: [PATCH 04/14] Adds test for concat function. --- lab-nathan/test/fp-test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lab-nathan/test/fp-test.js b/lab-nathan/test/fp-test.js index 3078821..8f74418 100644 --- a/lab-nathan/test/fp-test.js +++ b/lab-nathan/test/fp-test.js @@ -17,4 +17,18 @@ describe('fp', function() { expect(result).to.equal([1, 3]); }); }); + + describe('#reduce()', function() { + it('should return 6.', function() { + let result = fp.reduce([1, 2, 3], (acc, cur) => acc + cur, 0); + expect(result).to.equal(6); + }); + }); + + describe('#concat()', function() { + it('should return [1, 2, 3, 4, 5, 6].', function() { + let result = fp.concat([1, 2, 3], [4, 5, 6]); + expect(result).to.equal([1, 2, 3, 4, 5, 6]); + }); + }); }); \ No newline at end of file From fda0e1962aa292b9401dc161056458615c34b115 Mon Sep 17 00:00:00 2001 From: Nathan Harrenstein Date: Tue, 18 Jul 2017 12:45:33 -0700 Subject: [PATCH 05/14] Adds test for splice function. --- lab-nathan/test/fp-test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lab-nathan/test/fp-test.js b/lab-nathan/test/fp-test.js index 8f74418..b18273d 100644 --- a/lab-nathan/test/fp-test.js +++ b/lab-nathan/test/fp-test.js @@ -31,4 +31,11 @@ describe('fp', function() { expect(result).to.equal([1, 2, 3, 4, 5, 6]); }); }); + + describe('#splice()', function() { + it('should return [1, 2, 3, 7, 8, 9, 4, 5, 6].', function() { + let result = fp.splice([1, 2, 3, 4, 5, 6], 3, [7, 8, 9]); + expect(result).to.equal([1, 2, 3, 7, 8, 9, 4, 5, 6]); + }); + }); }); \ No newline at end of file From eabe0d192c845e1352b02befe0234dfca4ad7f17 Mon Sep 17 00:00:00 2001 From: Nathan Harrenstein Date: Tue, 18 Jul 2017 12:55:14 -0700 Subject: [PATCH 06/14] Adds map function. --- lab-nathan/lib/fp.js | 8 ++++++++ lab-nathan/test/fp-test.js | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lab-nathan/lib/fp.js b/lab-nathan/lib/fp.js index e69de29..917c33b 100644 --- a/lab-nathan/lib/fp.js +++ b/lab-nathan/lib/fp.js @@ -0,0 +1,8 @@ +'use strict'; + +let fp = {}; +module.exports = fp; + +fp.map = (array, callback) => { + return Array.prototype.map.call(array, callback); +}; \ No newline at end of file diff --git a/lab-nathan/test/fp-test.js b/lab-nathan/test/fp-test.js index b18273d..6ab5485 100644 --- a/lab-nathan/test/fp-test.js +++ b/lab-nathan/test/fp-test.js @@ -7,7 +7,7 @@ describe('fp', function() { describe('#map()', function() { it('should return an array of doubled values.', function() { let result = fp.map([1, 2, 3], num => num * 2); - expect(result).to.equal([2, 4, 6]); + expect(result).to.deep.equal([2, 4, 6]); }); }); @@ -28,14 +28,14 @@ describe('fp', function() { describe('#concat()', function() { it('should return [1, 2, 3, 4, 5, 6].', function() { let result = fp.concat([1, 2, 3], [4, 5, 6]); - expect(result).to.equal([1, 2, 3, 4, 5, 6]); + expect(result).to.deep.equal([1, 2, 3, 4, 5, 6]); }); }); describe('#splice()', function() { it('should return [1, 2, 3, 7, 8, 9, 4, 5, 6].', function() { let result = fp.splice([1, 2, 3, 4, 5, 6], 3, [7, 8, 9]); - expect(result).to.equal([1, 2, 3, 7, 8, 9, 4, 5, 6]); + expect(result).to.deep.equal([1, 2, 3, 7, 8, 9, 4, 5, 6]); }); }); }); \ No newline at end of file From f87ed27f87313b5bc8ee10822d5b18af861db6cd Mon Sep 17 00:00:00 2001 From: Nathan Harrenstein Date: Tue, 18 Jul 2017 12:58:33 -0700 Subject: [PATCH 07/14] Adds filter function. --- lab-nathan/lib/fp.js | 5 ++--- lab-nathan/test/fp-test.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lab-nathan/lib/fp.js b/lab-nathan/lib/fp.js index 917c33b..58801b3 100644 --- a/lab-nathan/lib/fp.js +++ b/lab-nathan/lib/fp.js @@ -3,6 +3,5 @@ let fp = {}; module.exports = fp; -fp.map = (array, callback) => { - return Array.prototype.map.call(array, callback); -}; \ No newline at end of file +fp.map = (array, callback) => Array.prototype.map.call(array, callback); +fp.filter = (array, predicate) => Array.prototype.filter.call(array, predicate); \ No newline at end of file diff --git a/lab-nathan/test/fp-test.js b/lab-nathan/test/fp-test.js index 6ab5485..37eb4ff 100644 --- a/lab-nathan/test/fp-test.js +++ b/lab-nathan/test/fp-test.js @@ -13,8 +13,8 @@ describe('fp', function() { describe('#filter()', function() { it('should return 2.', function() { - let result = fp.filter([1, 2, 3], 2); - expect(result).to.equal([1, 3]); + let result = fp.filter([1, 2, 3], num => num !== 2); + expect(result).to.deep.equal([1, 3]); }); }); From 1682378fd34f603d6db1a72e807dc72b58f27035 Mon Sep 17 00:00:00 2001 From: Nathan Harrenstein Date: Tue, 18 Jul 2017 13:12:27 -0700 Subject: [PATCH 08/14] Adds reduce function. --- lab-nathan/lib/fp.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lab-nathan/lib/fp.js b/lab-nathan/lib/fp.js index 58801b3..af299be 100644 --- a/lab-nathan/lib/fp.js +++ b/lab-nathan/lib/fp.js @@ -3,5 +3,14 @@ let fp = {}; module.exports = fp; -fp.map = (array, callback) => Array.prototype.map.call(array, callback); -fp.filter = (array, predicate) => Array.prototype.filter.call(array, predicate); \ No newline at end of file +fp.map = (array, func) => { + return Array.prototype.map.call(array, func); +}; + +fp.filter = (array, predicate) => { + return Array.prototype.filter.call(array, predicate); +}; + +fp.reduce = (array, func, initialValue) => { + return Array.prototype.reduce.call(array, func, initialValue); +}; \ No newline at end of file From 75da7c06ba898938d4500990e4a2d5c912cfce4b Mon Sep 17 00:00:00 2001 From: Nathan Harrenstein Date: Tue, 18 Jul 2017 13:15:52 -0700 Subject: [PATCH 09/14] Adds concat function. --- lab-nathan/lib/fp.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lab-nathan/lib/fp.js b/lab-nathan/lib/fp.js index af299be..c667bb0 100644 --- a/lab-nathan/lib/fp.js +++ b/lab-nathan/lib/fp.js @@ -13,4 +13,8 @@ fp.filter = (array, predicate) => { fp.reduce = (array, func, initialValue) => { return Array.prototype.reduce.call(array, func, initialValue); +}; + +fp.concat = (arrayA, arrayB) => { + return Array.prototype.concat.call(arrayA, arrayB); }; \ No newline at end of file From 50d2cf936b2d8db46845b214242fd3a4f2f57f12 Mon Sep 17 00:00:00 2001 From: Nathan Harrenstein Date: Tue, 18 Jul 2017 13:49:56 -0700 Subject: [PATCH 10/14] Adds splice function. --- lab-nathan/lib/fp.js | 5 +++++ lab-nathan/test/fp-test.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lab-nathan/lib/fp.js b/lab-nathan/lib/fp.js index c667bb0..8a4cd1d 100644 --- a/lab-nathan/lib/fp.js +++ b/lab-nathan/lib/fp.js @@ -17,4 +17,9 @@ fp.reduce = (array, func, initialValue) => { fp.concat = (arrayA, arrayB) => { return Array.prototype.concat.call(arrayA, arrayB); +}; + +fp.splice = (array, start, deleteCount, items) => { + Array.prototype.splice.call(array, start, deleteCount, ...items); + return array; }; \ No newline at end of file diff --git a/lab-nathan/test/fp-test.js b/lab-nathan/test/fp-test.js index 37eb4ff..accc39a 100644 --- a/lab-nathan/test/fp-test.js +++ b/lab-nathan/test/fp-test.js @@ -34,7 +34,7 @@ describe('fp', function() { describe('#splice()', function() { it('should return [1, 2, 3, 7, 8, 9, 4, 5, 6].', function() { - let result = fp.splice([1, 2, 3, 4, 5, 6], 3, [7, 8, 9]); + let result = fp.splice([1, 2, 3, 4, 5, 6], 3, 0, [7, 8, 9]); expect(result).to.deep.equal([1, 2, 3, 7, 8, 9, 4, 5, 6]); }); }); From fb01aaedb335a33c6ce3c71a841cbcd3d6117a50 Mon Sep 17 00:00:00 2001 From: Nathan Harrenstein Date: Tue, 18 Jul 2017 13:57:55 -0700 Subject: [PATCH 11/14] Use only lexical arrow functions. --- lab-nathan/test/fp-test.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lab-nathan/test/fp-test.js b/lab-nathan/test/fp-test.js index accc39a..ca85ca5 100644 --- a/lab-nathan/test/fp-test.js +++ b/lab-nathan/test/fp-test.js @@ -3,37 +3,37 @@ const fp = require('../lib/fp.js'); const expect = require('chai').expect; -describe('fp', function() { - describe('#map()', function() { - it('should return an array of doubled values.', function() { +describe('fp', () => { + describe('#map()', () => { + it('should return an array of doubled values.', () => { let result = fp.map([1, 2, 3], num => num * 2); expect(result).to.deep.equal([2, 4, 6]); }); }); - describe('#filter()', function() { - it('should return 2.', function() { + describe('#filter()', () => { + it('should return 2.', () => { let result = fp.filter([1, 2, 3], num => num !== 2); expect(result).to.deep.equal([1, 3]); }); }); - describe('#reduce()', function() { - it('should return 6.', function() { + describe('#reduce()', () => { + it('should return 6.', () => { let result = fp.reduce([1, 2, 3], (acc, cur) => acc + cur, 0); expect(result).to.equal(6); }); }); - describe('#concat()', function() { - it('should return [1, 2, 3, 4, 5, 6].', function() { + describe('#concat()', () => { + it('should return [1, 2, 3, 4, 5, 6].', () => { let result = fp.concat([1, 2, 3], [4, 5, 6]); expect(result).to.deep.equal([1, 2, 3, 4, 5, 6]); }); }); - describe('#splice()', function() { - it('should return [1, 2, 3, 7, 8, 9, 4, 5, 6].', function() { + describe('#splice()', () => { + it('should return [1, 2, 3, 7, 8, 9, 4, 5, 6].', () => { let result = fp.splice([1, 2, 3, 4, 5, 6], 3, 0, [7, 8, 9]); expect(result).to.deep.equal([1, 2, 3, 7, 8, 9, 4, 5, 6]); }); From 877d6e70e450dce2bd85ae44c42851b1c204eba6 Mon Sep 17 00:00:00 2001 From: Nathan Harrenstein Date: Tue, 18 Jul 2017 14:55:11 -0700 Subject: [PATCH 12/14] Adds bonus. --- lab-nathan/index.js | 5 +++++ lab-nathan/package.json | 1 + 2 files changed, 6 insertions(+) create mode 100644 lab-nathan/index.js diff --git a/lab-nathan/index.js b/lab-nathan/index.js new file mode 100644 index 0000000..5fced61 --- /dev/null +++ b/lab-nathan/index.js @@ -0,0 +1,5 @@ +'use strict'; + +const fp = require('./lib/fp.js'); + +fp.map(process.argv.slice(2), a => console.log(a.toUpperCase())); \ No newline at end of file diff --git a/lab-nathan/package.json b/lab-nathan/package.json index 530d510..fd82602 100644 --- a/lab-nathan/package.json +++ b/lab-nathan/package.json @@ -4,6 +4,7 @@ "description": "", "main": "index.js", "scripts": { + "start": "node index.js", "lint": "eslint .", "test": "mocha" }, From fb5c6e65b92b57a64a72ed4ea12b9aedae7df762 Mon Sep 17 00:00:00 2001 From: Nathan Harrenstein Date: Tue, 18 Jul 2017 14:58:44 -0700 Subject: [PATCH 13/14] Refactor. --- lab-nathan/lib/fp.js | 20 ++++---------------- lab-nathan/test/fp-test.js | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/lab-nathan/lib/fp.js b/lab-nathan/lib/fp.js index 8a4cd1d..09cbe80 100644 --- a/lab-nathan/lib/fp.js +++ b/lab-nathan/lib/fp.js @@ -3,22 +3,10 @@ let fp = {}; module.exports = fp; -fp.map = (array, func) => { - return Array.prototype.map.call(array, func); -}; - -fp.filter = (array, predicate) => { - return Array.prototype.filter.call(array, predicate); -}; - -fp.reduce = (array, func, initialValue) => { - return Array.prototype.reduce.call(array, func, initialValue); -}; - -fp.concat = (arrayA, arrayB) => { - return Array.prototype.concat.call(arrayA, arrayB); -}; - +fp.map = (array, func) => Array.prototype.map.call(array, func); +fp.filter = (array, predicate) => Array.prototype.filter.call(array, predicate); +fp.reduce = (array, func, initialValue) => Array.prototype.reduce.call(array, func, initialValue); +fp.concat = (arrayA, arrayB) => Array.prototype.concat.call(arrayA, arrayB); fp.splice = (array, start, deleteCount, items) => { Array.prototype.splice.call(array, start, deleteCount, ...items); return array; diff --git a/lab-nathan/test/fp-test.js b/lab-nathan/test/fp-test.js index ca85ca5..53f9e11 100644 --- a/lab-nathan/test/fp-test.js +++ b/lab-nathan/test/fp-test.js @@ -5,6 +5,10 @@ const expect = require('chai').expect; describe('fp', () => { describe('#map()', () => { + it('should fail with invalid inputs.', () => { + expect(fp.map).to.throw(Error); + }); + it('should return an array of doubled values.', () => { let result = fp.map([1, 2, 3], num => num * 2); expect(result).to.deep.equal([2, 4, 6]); @@ -12,6 +16,10 @@ describe('fp', () => { }); describe('#filter()', () => { + it('should fail with invalid inputs.', () => { + expect(fp.filter).to.throw(Error); + }); + it('should return 2.', () => { let result = fp.filter([1, 2, 3], num => num !== 2); expect(result).to.deep.equal([1, 3]); @@ -19,6 +27,10 @@ describe('fp', () => { }); describe('#reduce()', () => { + it('should fail with invalid inputs.', () => { + expect(fp.reduce).to.throw(Error); + }); + it('should return 6.', () => { let result = fp.reduce([1, 2, 3], (acc, cur) => acc + cur, 0); expect(result).to.equal(6); @@ -26,6 +38,10 @@ describe('fp', () => { }); describe('#concat()', () => { + it('should fail with invalid inputs.', () => { + expect(fp.concat).to.throw(Error); + }); + it('should return [1, 2, 3, 4, 5, 6].', () => { let result = fp.concat([1, 2, 3], [4, 5, 6]); expect(result).to.deep.equal([1, 2, 3, 4, 5, 6]); @@ -33,6 +49,10 @@ describe('fp', () => { }); describe('#splice()', () => { + it('should fail with invalid inputs.', () => { + expect(fp.splice).to.throw(Error); + }); + it('should return [1, 2, 3, 7, 8, 9, 4, 5, 6].', () => { let result = fp.splice([1, 2, 3, 4, 5, 6], 3, 0, [7, 8, 9]); expect(result).to.deep.equal([1, 2, 3, 7, 8, 9, 4, 5, 6]); From 9db0c3c0053cdb889df8997c32d52c1b3f3dc686 Mon Sep 17 00:00:00 2001 From: Nathan Harrenstein Date: Tue, 18 Jul 2017 17:08:04 -0700 Subject: [PATCH 14/14] Add CLI test. --- lab-nathan/test/index-test.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lab-nathan/test/index-test.js diff --git a/lab-nathan/test/index-test.js b/lab-nathan/test/index-test.js new file mode 100644 index 0000000..5c97298 --- /dev/null +++ b/lab-nathan/test/index-test.js @@ -0,0 +1,23 @@ +'use strict'; + +const expect = require('chai').expect; +const { spawn } = require('child_process'); + +describe('index', () => { + it('should produce uppercase params.', done => { + let child = spawn('node', ['index.js', 'hi', 'hello'], { + shell: true, + }); + + let buffer = []; + + child.stdout.on('data', chunk => { + buffer.push(chunk.toString().trim()); + }); + + child.stdout.on('end', () => { + expect(buffer.join(' ')).to.equal('HI HELLO'); + done(); + }); + }); +}); \ No newline at end of file