1 Star 0 Fork 0

imagemin-cn / imagemin-jpegtran

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
test.js 825 Bytes
一键复制 编辑 原始数据 按行查看 历史
Shogo Sensui 提交于 2019-01-13 17:29 . Use Travis to test on Windows (#22)
import fs from 'fs';
import path from 'path';
import isJpg from 'is-jpg';
import isProgressive from 'is-progressive';
import pify from 'pify';
import test from 'ava';
import m from '.';
const fsP = pify(fs);
test('optimize a JPG', async t => {
const buf = await fsP.readFile(path.join(__dirname, 'fixture.jpg'));
const data = await m()(buf);
t.true(data.length < buf.length);
t.true(isJpg(data));
});
test('throw error when a JPG is corrupt', async t => {
const buf = await fsP.readFile(path.join(__dirname, 'fixture-corrupt.jpg'));
await t.throwsAsync(async () => {
await m()(buf);
}, /Corrupt JPEG data/);
});
test('progressive option', async t => {
const buf = await fsP.readFile(path.join(__dirname, 'fixture.jpg'));
const data = await m({progressive: true})(buf);
t.true(isProgressive.buffer(data));
});
1
https://gitee.com/imagemin-cn/imagemin-jpegtran.git
git@gitee.com:imagemin-cn/imagemin-jpegtran.git
imagemin-cn
imagemin-jpegtran
imagemin-jpegtran
master

搜索帮助