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
await b()
let expected const output = hexo.route.get(path.concat('.br'))
try { const buf = []
await brotli(input, { params: { [zlib.constants.BROTLI_PARAM_QUALITY]: level } }) output.on('data', (chunk) => (buf.push(chunk)))
} catch (err) { output.on('end', async () => {
expected = err.message const result = Buffer.concat(buf)
} const expected = await brotli(input, { params: { [zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY } })
try {
await b() expect(result.toString('base64')).toBe(Buffer.from(expected, 'binary').toString('base64'))
} catch (err) { })
expect(err.message).toContain(expected)
}
}) })
test('include - exclude non-text file by default', async () => { test('include - exclude non-text file by default', async () => {