From 866593110e7453a7441ee51b3a48c89b95df9e14 Mon Sep 17 00:00:00 2001 From: curbengh <43627182+curbengh@users.noreply.github.com> Date: Fri, 27 Dec 2019 08:09:31 +0000 Subject: [PATCH] test(br): test passing option --- test/filter.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/filter.test.js b/test/filter.test.js index 30a2849..606ce4a 100644 --- a/test/filter.test.js +++ b/test/filter.test.js @@ -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