From 81c96a5c69301602863e74223e795e670cd3f97d Mon Sep 17 00:00:00 2001 From: Predrag Josifovic Date: Wed, 29 Nov 2017 15:55:53 -0800 Subject: [PATCH 1/5] Organizing file structure, adding eslint and jest devDep and creating reader.js file --- .DS_Store | Bin 0 -> 6148 bytes lab-pedja/.eslintignore | 5 + lab-pedja/.eslintrc.json | 26 + lab-pedja/.gitignore | 148 + README.md => lab-pedja/README.md | 0 lab-pedja/__test__/reader.test.js | 1 + lab-pedja/lib/reader.js | 1 + lab-pedja/package-lock.json | 4756 +++++++++++++++++++++++++++++ lab-pedja/package.json | 16 + 9 files changed, 4953 insertions(+) create mode 100644 .DS_Store create mode 100644 lab-pedja/.eslintignore create mode 100644 lab-pedja/.eslintrc.json create mode 100644 lab-pedja/.gitignore rename README.md => lab-pedja/README.md (100%) create mode 100644 lab-pedja/__test__/reader.test.js create mode 100644 lab-pedja/lib/reader.js create mode 100644 lab-pedja/package-lock.json create mode 100644 lab-pedja/package.json diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Wed, 29 Nov 2017 16:06:28 -0800 Subject: [PATCH 2/5] adding text files to assets folder --- lab-pedja/assets/file1.txt | 1 + lab-pedja/assets/file2.txt | 1 + lab-pedja/assets/file3.txt | 1 + 3 files changed, 3 insertions(+) create mode 100644 lab-pedja/assets/file1.txt create mode 100644 lab-pedja/assets/file2.txt create mode 100644 lab-pedja/assets/file3.txt diff --git a/lab-pedja/assets/file1.txt b/lab-pedja/assets/file1.txt new file mode 100644 index 0000000..27e6ea8 --- /dev/null +++ b/lab-pedja/assets/file1.txt @@ -0,0 +1 @@ +Stare out the window refuse to leave cardboard box so rub face on everything kitty loves pigs, yet have a lot of grump in yourself because you can't forget to be grumpy and not be like king grumpy cat but put butt in owner's face if it fits, i sits. Human give me attention meow attack the dog then pretend like nothing happened yet chase mice, so poop on grasses or lick the other cats cat mojo mrow. My slave human didn't give me any food so i pooped on the floor thinking longingly about tuna brine but cat is love, cat is life wake up human for food at 4am. Eat too much then proceed to regurgitate all over living room carpet while humans eat dinner i'm going to lap some water out of my master's cup meow spot something, big eyes, big eyes, crouch, shake butt, prepare to pounce so if it fits, i sits. Chew foot eat all the power cords find a way to fit in tiny box, destroy the blinds. Cats secretly make all the worlds muffins cats making all the muffins so sit in window and stare oooh, a bird, yum scratch me there, elevator butt meow meow, i tell my human. Cough furball groom yourself 4 hours - checked, have your beauty sleep 18 hours - checked, be fabulous for the rest of the day - checked but show belly open the door, let me out, let me out, let me-out, let me-aow, let meaow, meaow! so kitty loves pigs why must they do that. I am the best eat prawns daintily with a claw then lick paws clean wash down prawns with a lap of carnation milk then retire to the warmest spot on the couch to claw at the fabric before taking a catnap but pooping rainbow while flying in a toasted bread costume in space push your water glass on the floor soft kitty warm kitty little ball of furr purr while eating. Sit and stare. Leave hair everywhere spot something, big eyes, big eyes, crouch, shake butt, prepare to pounce i'm going to lap some water out of my master's cup meow or kick up litter but lick arm hair hide when guests come over. Lick plastic bags who's the baby toilet paper attack claws fluff everywhere meow miao french ciao litterbox stare at ceiling light, yet be a nyan cat, feel great about it, be annoying 24/7 poop rainbows in litter box all day a nice warm laptop for me to sit on thinking longingly about tuna brine. Have my breakfast spaghetti yarn cats secretly make all the worlds muffins but ears back wide eyed meowing non stop for food. Plan steps for world domination. Drink water out of the faucet jumps off balcony gives owner dead mouse at present then poops in litter box snatches yarn and fights with dog cat chases laser then plays in grass finds tiny spot in cupboard and sleeps all day jumps in bathtub and meows when owner fills food dish the cat knocks over the food dish cat slides down the water slide and into pool and swims even though it does not like water so always hungry yet lick the other cats so ignore the squirrels, you'll never catch them anyway for thug cat , yet chase red laser dot. Eat a plant, kill a hand scratch the postman wake up lick paw wake up owner meow meow and annoy owner until he gives you food say meow repeatedly until belly rubs, feels good for destroy couch as revenge. Purr when being pet pee in human's bed until he cleans the litter box chase red laser dot or love to play with owner's hair tie caticus cuteicus licks your face. Eat grass, throw it back up all of a sudden cat goes crazy. Leave fur on owners clothes. Have secret plans. Claw at curtains stretch and yawn nibble on tuna ignore human bite human hand meow to be let out or caticus cuteicus please stop looking at your phone and pet me so make meme, make cute face. Steal the warm chair right after you get up burrow under covers. diff --git a/lab-pedja/assets/file2.txt b/lab-pedja/assets/file2.txt new file mode 100644 index 0000000..f012e01 --- /dev/null +++ b/lab-pedja/assets/file2.txt @@ -0,0 +1 @@ +Have my breakfast spaghetti yarn intrigued by the shower. Eat from dog's food. Spread kitty litter all over house scamper but proudly present butt to human and if it fits, i sits lick face hiss at owner, pee a lot, and meow repeatedly scratch at fence purrrrrr eat muffins and poutine until owner comes back for roll on the floor purring your whiskers off. Ask to go outside and ask to come inside and ask to go outside and ask to come inside knock over christmas tree toilet paper attack claws fluff everywhere meow miao french ciao litterbox your pillow is now my pet bed but thinking longingly about tuna brine cat is love, cat is life bleghbleghvomit my furball really tie the room together. Caticus cuteicus step on your keyboard while you're gaming and then turn in a circle , i could pee on this if i had the energy. Climb leg. Eat prawns daintily with a claw then lick paws clean wash down prawns with a lap of carnation milk then retire to the warmest spot on the couch to claw at the fabric before taking a catnap cough or cats making all the muffins destroy the blinds so intrigued by the shower spend all night ensuring people don't sleep sleep all day lick the other cats. Hide from vacuum cleaner shove bum in owner's face like camera lens but chew iPad power cord. Chew iPad power cord the fat cat sat on the mat bat away with paws or decide to want nothing to do with my owner today jump launch to pounce upon little yarn mouse, bare fangs at toy run hide in litter box until treats are fed and meow, so this cat happen now, it was too purr-fect!!! eat all the power cords. Sleep nap i'm going to lap some water out of my master's cup meow or toilet paper attack claws fluff everywhere meow miao french ciao litterbox cats go for world domination. Meow all night eat a plant, kill a hand. Always hungry wack the mini furry mouse, yet spread kitty litter all over house. Mice need to chase tail, yet ears back wide eyed massacre a bird in the living room and then look like the cutest and most innocent animal on the planet. Eat owner's food brown cats with pink ears, yet climb leg mesmerizing birds yet chew foot, for throwup on your pillow eat grass, throw it back up. Chase the pig around the house. Head nudges sniff sniff, or intently stare at the same spot chew iPad power cord pushes butt to face, for hiss at vacuum cleaner or open the door, let me out, let me out, let me-out, let me-aow, let meaow, meaow!. Pounce on unsuspecting person spot something, big eyes, big eyes, crouch, shake butt, prepare to pounce rub face on everything, make muffins. And sometimes switches in french and say "miaou" just because well why not your pillow is now my pet bed eat grass, throw it back up stares at human while pushing stuff off a table cereal boxes make for five star accommodation . Spread kitty litter all over house chew iPad power cord i could pee on this if i had the energy, and going to catch the red dot today going to catch the red dot today and more napping, more napping all the napping is exhausting. diff --git a/lab-pedja/assets/file3.txt b/lab-pedja/assets/file3.txt new file mode 100644 index 0000000..cfa77f1 --- /dev/null +++ b/lab-pedja/assets/file3.txt @@ -0,0 +1 @@ +Mesmerizing birds spend all night ensuring people don't sleep sleep all day, meow for food, then when human fills food dish, take a few bites of food and continue meowing swat at dog. Wake up human for food at 4am meow to be let in. Be a nyan cat, feel great about it, be annoying 24/7 poop rainbows in litter box all day. Roll over and sun my belly get video posted to internet for chasing red dot eat plants, meow, and throw up because i ate plants munch on tasty moths crash against wall but walk away like nothing happened always hungry drink water out of the faucet. Litter kitter kitty litty little kitten big roar roar feed me. Cat dog hate mouse eat string barf pillow no baths hate everything. Leave fur on owners clothes destroy the blinds, eat and than sleep on your face or purr but meowing non stop for food. Find something else more interesting i am the best but this cat happen now, it was too purr-fect!!!. Suddenly go on wild-eyed crazy rampage cat not kitten around yet woops poop hanging from butt must get rid run run around house drag poop on floor maybe it comes off woops left brown marks on floor human slave clean lick butt now wake up human for food at 4am and lick the plastic bag. Destroy couch. Pose purrfectly to show my beauty inspect anything brought into the house. Eat grass, throw it back up brown cats with pink ears so give me attention or face the wrath of my claws kitty scratches couch bad kitty play time chase mice. Roll over and sun my belly hide head under blanket so no one can see. From 41e93e1a0a46ca6bbea256e207f5d0e3646b22e1 Mon Sep 17 00:00:00 2001 From: Predrag Josifovic Date: Wed, 29 Nov 2017 18:51:30 -0800 Subject: [PATCH 3/5] finally passing test - adding text from files to single array as its items --- lab-pedja/__test__/reader.test.js | 17 +++++++++++++++++ lab-pedja/assets/file1.txt | 2 +- lab-pedja/assets/file2.txt | 2 +- lab-pedja/assets/file3.txt | 2 +- lab-pedja/lib/reader.js | 24 ++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 3 deletions(-) diff --git a/lab-pedja/__test__/reader.test.js b/lab-pedja/__test__/reader.test.js index ad9a93a..841e08f 100644 --- a/lab-pedja/__test__/reader.test.js +++ b/lab-pedja/__test__/reader.test.js @@ -1 +1,18 @@ 'use strict'; + +const fileReader = require('../lib/reader'); + +const paths = [ + `${__dirname}/../assets/file1.txt`, + `${__dirname}/../assets/file2.txt`, + `${__dirname}/../assets/file3.txt`]; + +describe('reader.test.js', () => { + test('If not error is found, text from all three files should be shown as an item in an array', (done) => { + fileReader.readFile(paths, (error,data) => { + expect(error).toBeNull(); + expect(data).toEqual(['file1\n','file2\n','file3\n']); + done(); + }); + }); +}); diff --git a/lab-pedja/assets/file1.txt b/lab-pedja/assets/file1.txt index 27e6ea8..e212970 100644 --- a/lab-pedja/assets/file1.txt +++ b/lab-pedja/assets/file1.txt @@ -1 +1 @@ -Stare out the window refuse to leave cardboard box so rub face on everything kitty loves pigs, yet have a lot of grump in yourself because you can't forget to be grumpy and not be like king grumpy cat but put butt in owner's face if it fits, i sits. Human give me attention meow attack the dog then pretend like nothing happened yet chase mice, so poop on grasses or lick the other cats cat mojo mrow. My slave human didn't give me any food so i pooped on the floor thinking longingly about tuna brine but cat is love, cat is life wake up human for food at 4am. Eat too much then proceed to regurgitate all over living room carpet while humans eat dinner i'm going to lap some water out of my master's cup meow spot something, big eyes, big eyes, crouch, shake butt, prepare to pounce so if it fits, i sits. Chew foot eat all the power cords find a way to fit in tiny box, destroy the blinds. Cats secretly make all the worlds muffins cats making all the muffins so sit in window and stare oooh, a bird, yum scratch me there, elevator butt meow meow, i tell my human. Cough furball groom yourself 4 hours - checked, have your beauty sleep 18 hours - checked, be fabulous for the rest of the day - checked but show belly open the door, let me out, let me out, let me-out, let me-aow, let meaow, meaow! so kitty loves pigs why must they do that. I am the best eat prawns daintily with a claw then lick paws clean wash down prawns with a lap of carnation milk then retire to the warmest spot on the couch to claw at the fabric before taking a catnap but pooping rainbow while flying in a toasted bread costume in space push your water glass on the floor soft kitty warm kitty little ball of furr purr while eating. Sit and stare. Leave hair everywhere spot something, big eyes, big eyes, crouch, shake butt, prepare to pounce i'm going to lap some water out of my master's cup meow or kick up litter but lick arm hair hide when guests come over. Lick plastic bags who's the baby toilet paper attack claws fluff everywhere meow miao french ciao litterbox stare at ceiling light, yet be a nyan cat, feel great about it, be annoying 24/7 poop rainbows in litter box all day a nice warm laptop for me to sit on thinking longingly about tuna brine. Have my breakfast spaghetti yarn cats secretly make all the worlds muffins but ears back wide eyed meowing non stop for food. Plan steps for world domination. Drink water out of the faucet jumps off balcony gives owner dead mouse at present then poops in litter box snatches yarn and fights with dog cat chases laser then plays in grass finds tiny spot in cupboard and sleeps all day jumps in bathtub and meows when owner fills food dish the cat knocks over the food dish cat slides down the water slide and into pool and swims even though it does not like water so always hungry yet lick the other cats so ignore the squirrels, you'll never catch them anyway for thug cat , yet chase red laser dot. Eat a plant, kill a hand scratch the postman wake up lick paw wake up owner meow meow and annoy owner until he gives you food say meow repeatedly until belly rubs, feels good for destroy couch as revenge. Purr when being pet pee in human's bed until he cleans the litter box chase red laser dot or love to play with owner's hair tie caticus cuteicus licks your face. Eat grass, throw it back up all of a sudden cat goes crazy. Leave fur on owners clothes. Have secret plans. Claw at curtains stretch and yawn nibble on tuna ignore human bite human hand meow to be let out or caticus cuteicus please stop looking at your phone and pet me so make meme, make cute face. Steal the warm chair right after you get up burrow under covers. +file1 diff --git a/lab-pedja/assets/file2.txt b/lab-pedja/assets/file2.txt index f012e01..6c493ff 100644 --- a/lab-pedja/assets/file2.txt +++ b/lab-pedja/assets/file2.txt @@ -1 +1 @@ -Have my breakfast spaghetti yarn intrigued by the shower. Eat from dog's food. Spread kitty litter all over house scamper but proudly present butt to human and if it fits, i sits lick face hiss at owner, pee a lot, and meow repeatedly scratch at fence purrrrrr eat muffins and poutine until owner comes back for roll on the floor purring your whiskers off. Ask to go outside and ask to come inside and ask to go outside and ask to come inside knock over christmas tree toilet paper attack claws fluff everywhere meow miao french ciao litterbox your pillow is now my pet bed but thinking longingly about tuna brine cat is love, cat is life bleghbleghvomit my furball really tie the room together. Caticus cuteicus step on your keyboard while you're gaming and then turn in a circle , i could pee on this if i had the energy. Climb leg. Eat prawns daintily with a claw then lick paws clean wash down prawns with a lap of carnation milk then retire to the warmest spot on the couch to claw at the fabric before taking a catnap cough or cats making all the muffins destroy the blinds so intrigued by the shower spend all night ensuring people don't sleep sleep all day lick the other cats. Hide from vacuum cleaner shove bum in owner's face like camera lens but chew iPad power cord. Chew iPad power cord the fat cat sat on the mat bat away with paws or decide to want nothing to do with my owner today jump launch to pounce upon little yarn mouse, bare fangs at toy run hide in litter box until treats are fed and meow, so this cat happen now, it was too purr-fect!!! eat all the power cords. Sleep nap i'm going to lap some water out of my master's cup meow or toilet paper attack claws fluff everywhere meow miao french ciao litterbox cats go for world domination. Meow all night eat a plant, kill a hand. Always hungry wack the mini furry mouse, yet spread kitty litter all over house. Mice need to chase tail, yet ears back wide eyed massacre a bird in the living room and then look like the cutest and most innocent animal on the planet. Eat owner's food brown cats with pink ears, yet climb leg mesmerizing birds yet chew foot, for throwup on your pillow eat grass, throw it back up. Chase the pig around the house. Head nudges sniff sniff, or intently stare at the same spot chew iPad power cord pushes butt to face, for hiss at vacuum cleaner or open the door, let me out, let me out, let me-out, let me-aow, let meaow, meaow!. Pounce on unsuspecting person spot something, big eyes, big eyes, crouch, shake butt, prepare to pounce rub face on everything, make muffins. And sometimes switches in french and say "miaou" just because well why not your pillow is now my pet bed eat grass, throw it back up stares at human while pushing stuff off a table cereal boxes make for five star accommodation . Spread kitty litter all over house chew iPad power cord i could pee on this if i had the energy, and going to catch the red dot today going to catch the red dot today and more napping, more napping all the napping is exhausting. +file2 diff --git a/lab-pedja/assets/file3.txt b/lab-pedja/assets/file3.txt index cfa77f1..7c8ac2f 100644 --- a/lab-pedja/assets/file3.txt +++ b/lab-pedja/assets/file3.txt @@ -1 +1 @@ -Mesmerizing birds spend all night ensuring people don't sleep sleep all day, meow for food, then when human fills food dish, take a few bites of food and continue meowing swat at dog. Wake up human for food at 4am meow to be let in. Be a nyan cat, feel great about it, be annoying 24/7 poop rainbows in litter box all day. Roll over and sun my belly get video posted to internet for chasing red dot eat plants, meow, and throw up because i ate plants munch on tasty moths crash against wall but walk away like nothing happened always hungry drink water out of the faucet. Litter kitter kitty litty little kitten big roar roar feed me. Cat dog hate mouse eat string barf pillow no baths hate everything. Leave fur on owners clothes destroy the blinds, eat and than sleep on your face or purr but meowing non stop for food. Find something else more interesting i am the best but this cat happen now, it was too purr-fect!!!. Suddenly go on wild-eyed crazy rampage cat not kitten around yet woops poop hanging from butt must get rid run run around house drag poop on floor maybe it comes off woops left brown marks on floor human slave clean lick butt now wake up human for food at 4am and lick the plastic bag. Destroy couch. Pose purrfectly to show my beauty inspect anything brought into the house. Eat grass, throw it back up brown cats with pink ears so give me attention or face the wrath of my claws kitty scratches couch bad kitty play time chase mice. Roll over and sun my belly hide head under blanket so no one can see. +file3 diff --git a/lab-pedja/lib/reader.js b/lab-pedja/lib/reader.js index ad9a93a..7cf62aa 100644 --- a/lab-pedja/lib/reader.js +++ b/lab-pedja/lib/reader.js @@ -1 +1,25 @@ 'use strict'; + +const fileReader = module.exports = {}; +const fs = require('fs'); + +fileReader.readFile = (paths, callback) => { + let returnedArray = []; + fs.readFile(paths[0], (error,data) => { + if(error) + return callback(error); + returnedArray.push(data.toString()); + }); + fs.readFile(paths[1], (error,data) => { + if(error) + return callback(error); + returnedArray.push(data.toString()); + }); + fs.readFile(paths[2], (error,data) => { + if(error) + return callback(error); + returnedArray.push(data.toString()); + console.log(returnedArray); + callback(null,returnedArray); + }); +}; From 7e8a9556ce2fddffd1585ed474471eb81c4967b7 Mon Sep 17 00:00:00 2001 From: Predrag Josifovic Date: Wed, 29 Nov 2017 18:54:00 -0800 Subject: [PATCH 4/5] adding edge case test for invalid file paths --- lab-pedja/__test__/reader.test.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lab-pedja/__test__/reader.test.js b/lab-pedja/__test__/reader.test.js index 841e08f..ee6b205 100644 --- a/lab-pedja/__test__/reader.test.js +++ b/lab-pedja/__test__/reader.test.js @@ -7,6 +7,11 @@ const paths = [ `${__dirname}/../assets/file2.txt`, `${__dirname}/../assets/file3.txt`]; +const invalidPaths = [ + `${__dirname}/../assets/file1.rtf`, + `${__dirname}/../assets/file2.rtf`, + `${__dirname}/../assets/file3.rtf`]; + describe('reader.test.js', () => { test('If not error is found, text from all three files should be shown as an item in an array', (done) => { fileReader.readFile(paths, (error,data) => { @@ -15,4 +20,10 @@ describe('reader.test.js', () => { done(); }); }); + test('If invalid file paths are used', (done) => { + fileReader.readFile(invalidPaths, (error) => { + expect(error).not.toBeNull(); + done(); + }); + }); }); From a6201ff40315290aa88d636fa111e202ce7d646d Mon Sep 17 00:00:00 2001 From: Predrag Josifovic Date: Wed, 29 Nov 2017 19:08:29 -0800 Subject: [PATCH 5/5] adding edge case for incorrect file path order and writing README.md file --- lab-pedja/README.md | 41 ++++++------------------------- lab-pedja/__test__/reader.test.js | 6 +++++ 2 files changed, 13 insertions(+), 34 deletions(-) diff --git a/lab-pedja/README.md b/lab-pedja/README.md index 8b9bed3..ca6b4e7 100644 --- a/lab-pedja/README.md +++ b/lab-pedja/README.md @@ -1,46 +1,19 @@ -![CF](https://camo.githubusercontent.com/70edab54bba80edb7493cad3135e9606781cbb6b/687474703a2f2f692e696d6775722e636f6d2f377635415363382e706e67) 03: Parallel File Processing +![CF](https://camo.githubusercontent.com/70edab54bba80edb7493cad3135e9606781cbb6b/687474703a2f2f692e696d6775722e636f6d2f377635415363382e706e67) 03: Lab Parallel File Processing === -## Submission Instructions -* Work in a fork of this repository -* Work in a branch on your fork -* Write all of your code in a directory named `lab-` + `` **e.g.** `lab-susan` -* Open a pull request to this repository -* Submit on canvas a question and observation, how long you spent, and a link to your pull request - -## Resources - * [fs module docs](https://nodejs.org/api/fs.html) - -## Configuration -Configure the root of your repository with the following files and directories. Thoughtfully name and organize any aditional configuration or module files. -* **README.md** - contains documentation -* **.gitignore** - contains a [robust](http://gitignore.io) `.gitignore` file -* **.eslintrc.json** - contains the course linter configuration -* **.eslintignore** - contains the course linter ignore configuration -* **package.json** - contains npm package config - * create a `lint` script for running eslint - * create a `test` script for running tests -* **lib/** - contains module definitions -* **assets/** - contains the text files used by the program -* **\_\_test\_\_/** - contains unit tests ## Feature Tasks #### Reader Module -In the lib/ directory create a reader.js module that exports a single function. The reader module should take an array of three file paths and resolve a mapped array of strings loaded from each file using an error-first callback. The string data should be in the same order as the file path data (mapped). If an error occurs it should immediately reject the error using the callback and stop execution. +In the lib/ directory reader.js `fileReader` module exports a single function. The reader module takes an array of three file paths and resolve a mapped array of strings loaded from each file. If an error occurs it should immediately reject the error using the callback and stop execution. -* The reader module should have the function signature `(paths, callback) => undefined` +* Function takes two parameters `(paths, callback)` where `paths` is an array with file paths that we will be joining. * On a failure the reader module should invoke the callback with an error `callback(error)` -* On success the reader module should invoke the callback with null as the first parameter, and the result as the second parameter `callback(null, result)` +* On success the reader module should invoke the callback with null as the first parameter, and the result as the second parameter `callback(null, result)` where `result` is newly created array of file paths. ## Testing #### Reader Module Tests -* Use TDD `describe` and `test` methods to define descriptive tests -* Each `test` callback should aim to test a small well defined feature of a function -* Write tests to ensure the reader function rejects errors with invalid file paths -* Write tests to ensure the reader function correctly resolves mapped string data for an array of file paths +* If not error is found, text from all three files should be shown as an item in an array. -## Bonus 1pt -Write the reader function recursively so that it will be able to support 0 or more paths. +* If invalid file paths are used, reader module invokes `callback(error)`. -## Documentation -In your README.md describe the exported values of each module you have defined. Every function description should include it's arity (expected number of parameters), the expected data for each parameter (data-type and limitations), and it's behavior (for both valid and invalid use). Feel free to write any additional information in your README.md. +* If the order of file paths is incorrect, reader module invokes `callback(error)`. diff --git a/lab-pedja/__test__/reader.test.js b/lab-pedja/__test__/reader.test.js index ee6b205..6f0d547 100644 --- a/lab-pedja/__test__/reader.test.js +++ b/lab-pedja/__test__/reader.test.js @@ -26,4 +26,10 @@ describe('reader.test.js', () => { done(); }); }); + test('If invalid file paths order is not correct, error will be thrown', (done) => { + fileReader.readFile([`${__dirname}/../assets/file2.txt`, `${__dirname}/../assets/file1.txt`, `${__dirname}/../assets/file3.txt`], (error) => { + expect(error).toBeNull(); + done(); + }); + }); });