test(br): invalid level

This commit is contained in:
curbengh 2019-12-27 09:12:27 +00:00
parent 1a5197b9c9
commit e59e3866b9
No known key found for this signature in database
GPG Key ID: 21EA847C35D6E034
1 changed files with 11 additions and 12 deletions

View File

@ -559,21 +559,20 @@ describe('brotli', () => {
}) })
}) })
test('option - invalid', async () => { test('option - level is string', async () => {
const level = 'foo' const level = 'foo'
hexo.config.minify.brotli.level = level hexo.config.minify.brotli.level = level
let expected
try {
await brotli(input, { params: { [zlib.constants.BROTLI_PARAM_QUALITY]: level } })
} catch (err) {
expected = err.message
}
try {
await b() await b()
} catch (err) {
expect(err.message).toContain(expected) const output = hexo.route.get(path.concat('.br'))
} const buf = []
output.on('data', (chunk) => (buf.push(chunk)))
output.on('end', async () => {
const result = Buffer.concat(buf)
const expected = await brotli(input, { params: { [zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY } })
expect(result.toString('base64')).toBe(Buffer.from(expected, 'binary').toString('base64'))
})
}) })
test('include - exclude non-text file by default', async () => { test('include - exclude non-text file by default', async () => {