Skip to content

Conversation

sueanyv
Copy link

@sueanyv sueanyv commented Feb 28, 2017

No description provided.

@@ -0,0 +1 @@
Hello this is test two
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should make your sample test different for each file. You are only reading the beginning of each string and they all start the same here. So you won't know which order they are coming out.


const fs = require('fs');

const fileReader = require('./lib/file-reader.js')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job requiring in your function.

fileReader(`${__dirname}/./data/two.txt`, function(err, data) {
if (err) throw err;
console.log('three:', data.toString('hex', 0, 8));
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should have one function that reads all three files 'in order'. Not a function that reads one file that you call three times. There is also no way with the way you are doing it here to guarantee that they come back in order.

if (err) callback(err);
return callback(null, data.toString('hex',0,8));
});
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are using the readFile function correctly to read a file. But you need to be reading all three files in order.

done();
});
});
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way you set up your test here is similar to the way that you should set up your function in the file-reader.js file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants