Skip to content

Commit

Permalink
Add unit tests for each of the named color channels
Browse files Browse the repository at this point in the history
  • Loading branch information
mhirsch committed Jul 8, 2016
1 parent fa3a9c1 commit 339f7a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Binary file added test/fixtures/expected/extract-green.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions test/unit/extractChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,31 @@ describe('Image channel extraction', function() {
});
});

it('Green channel', function(done) {
sharp(fixtures.inputJpg)
.extractChannel('green')
.resize(320,240)
.toBuffer(function(err, data, info) {
if (err) throw err;
assert.strictEqual(320, info.width);
assert.strictEqual(240, info.height);
fixtures.assertSimilar(fixtures.expected('extract-green.jpg'), data, { threshold: 8 }, done);
});
});

it('Blue channel', function(done) {
sharp(fixtures.inputJpg)
.extractChannel('blue')
.resize(320,240)
.toBuffer(function(err, data, info) {
if (err) throw err;
assert.strictEqual(320, info.width);
assert.strictEqual(240, info.height);
fixtures.assertSimilar(fixtures.expected('extract-blue.jpg'), data, { threshold: 8 }, done);
});
});

it('Blue channel by number', function(done) {
sharp(fixtures.inputJpg)
.extractChannel(2)
.resize(320,240)
Expand Down

0 comments on commit 339f7a6

Please sign in to comment.