Skip to content

Comments

Logan-Luis-Nick-Bitmap-Final#14

Open
loganabsher wants to merge 29 commits intocodefellows-javascript-401d17:masterfrom
loganabsher:master
Open

Logan-Luis-Nick-Bitmap-Final#14
loganabsher wants to merge 29 commits intocodefellows-javascript-401d17:masterfrom
loganabsher:master

Conversation

@loganabsher
Copy link

No description provided.

expect(err).to.equal(null);
fileReader.writeNew(`${__dirname}/../assets/palette-write-bitmap.bmp`, data);
expect(data).to.not.equal(null);
fileReader.eraseFile(`${__dirname}/../assets/palette-write-bitmap.bmp`);
Copy link

Choose a reason for hiding this comment

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

You are calling this as cleanup but you aren't proving that this works or anything. In fact I would expect this to be the last thing but the file is still there when the tests are done. You should structure your callbacks to ensure that they don't move on at the wrong time.

fileReader.eraseFile(`${__dirname}/../assets/palette-invert-bitmap.bmp`);
index.invertBitmap();
fileReader.initFile(`${__dirname}/../assets/palette-invert-bitmap.bmp`, (err, data) => {
expect(err).to.equal(null);
Copy link

Choose a reason for hiding this comment

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

Instead of having all the invert bitmap do all the work and then re-reading the file to check if it is good you should structure your code a bit differently so that you can get the results of what you just wrote so you can easily test it without reading the file again. Right now you aren't proving that you aren't reading an empty string. 'I don't think you are but you want to show that you are.'

});
};

ColorTransform.prototype.rotateImage = function(bitmap) {
Copy link

Choose a reason for hiding this comment

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

This will handle 180 transforms so a good name for it would be flip rather than rotate.

});
};

ColorTransform.prototype.blueShift = function (bitmap) {
Copy link

Choose a reason for hiding this comment

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

This seems to be turning the bmp very red.

let g = parseInt(hexArray[1], 16);
let b = parseInt(hexArray[2], 16);
let invertR = (Math.ceil(r * 0.1)).toString(16);
let invertG = (Math.ceil(g * 0.1)).toString(16);
Copy link

Choose a reason for hiding this comment

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

This isn't really an invert. A better var name would be shiftR.

@@ -0,0 +1,20 @@
'use strict';
Copy link

Choose a reason for hiding this comment

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

bitmap constructor looks good.

};

exports.eraseFile = (path) => {
return fs.writeFile(path, '', (err, data) => {
Copy link

Choose a reason for hiding this comment

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

While this does change the contents of the file there is a better command from fs.unlink that would have erased the file entirely. Leaving it as an empty string can make it seem like there is still a relevant file.

module.exports = exports = {};

exports.invertBitmap = () => {
let onRead = (err, data) => {
Copy link

Choose a reason for hiding this comment

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

This seems like an unnecessary wrapper. Would be more straight forward to have the file helper at top and then could define function. That would flow easier for later reading.


module.exports = exports = {};

exports.invertBitmap = () => {
Copy link

Choose a reason for hiding this comment

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

Not taking in a path from anywhere on this means that you only have access to one bitmap file and can't test multiple. It would be good to keep this modular in case you want to read other bitmap files.

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.

4 participants