Remove gm dependency and update tests.
This commit is contained in:
parent
b1ceba7664
commit
75a46212da
8 changed files with 61 additions and 37 deletions
|
@ -3,14 +3,33 @@ import path from 'path';
|
|||
import assert from 'assert';
|
||||
import tmp from 'tmp';
|
||||
import resize from '../../lib/resize';
|
||||
import imageType from 'image-type';
|
||||
|
||||
const file = fs.readFileSync(path.join(__dirname, '..', 'fixtures', 'utah-arches.jpg'));
|
||||
|
||||
describe('Image resizing', function() {
|
||||
it('should resize an image', function*() {
|
||||
describe('Image resizing', () => {
|
||||
it('should resize a jpg', function* resizeImage() {
|
||||
const file = fs.readFileSync(path.join(__dirname, '..', 'fixtures', 'utah-arches.jpg'));
|
||||
const imageBuffer = yield resize(file, {height: 100, width: 100});
|
||||
const tmpFile = tmp.tmpNameSync();
|
||||
fs.writeFileSync(tmpFile + '.jpg', imageBuffer);
|
||||
assert(tmpFile);
|
||||
const tmpFile = tmp.tmpNameSync() + '.jpg';
|
||||
fs.writeFileSync(tmpFile, imageBuffer);
|
||||
const type = imageType(fs.readFileSync(tmpFile));
|
||||
assert(type.ext === 'jpg');
|
||||
});
|
||||
|
||||
it('should resize a png', function* resizeImage() {
|
||||
const file = fs.readFileSync(path.join(__dirname, '..', 'fixtures', 'app-icon.png'));
|
||||
const imageBuffer = yield resize(file, {height: 100, width: 100});
|
||||
const tmpFile = tmp.tmpNameSync() + '.png';
|
||||
fs.writeFileSync(tmpFile, imageBuffer);
|
||||
const type = imageType(fs.readFileSync(tmpFile));
|
||||
assert(type.ext === 'png');
|
||||
});
|
||||
|
||||
it('should resize a gif', function* resizeImage() {
|
||||
const file = fs.readFileSync(path.join(__dirname, '..', 'fixtures', 'kim.gif'));
|
||||
const imageBuffer = yield resize(file, {height: 100, width: 100});
|
||||
const tmpFile = tmp.tmpNameSync() + '.gif';
|
||||
fs.writeFileSync(tmpFile, imageBuffer);
|
||||
const type = imageType(fs.readFileSync(tmpFile));
|
||||
assert(type.ext === 'gif');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue