test(br): test passing option

This commit is contained in:
curbengh 2019-12-27 08:09:31 +00:00
parent f0b37aaf45
commit 866593110e
No known key found for this signature in database
GPG Key ID: 21EA847C35D6E034
1 changed files with 16 additions and 0 deletions

View File

@ -533,6 +533,22 @@ describe('brotli', () => {
expect(result).toBeUndefined()
})
test('option', async () => {
const level = 1
hexo.config.minify.brotli.level = level
await b()
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]: level } })
expect(result.toString('base64')).toBe(Buffer.from(expected, 'binary').toString('base64'))
})
})
test('option - invalid', async () => {
const level = 'foo'
hexo.config.minify.brotli.level = level