From f7c600545b4ced839bc2723b63751fa6e56c7e78 Mon Sep 17 00:00:00 2001 From: curbengh <43627182+curbengh@users.noreply.github.com> Date: Thu, 26 Dec 2019 15:24:54 +0000 Subject: [PATCH] test: option.enable --- test/filter.test.js | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/test/filter.test.js b/test/filter.test.js index 43b63c1..7b235ce 100644 --- a/test/filter.test.js +++ b/test/filter.test.js @@ -11,7 +11,7 @@ describe('html', () => { const Htmlminifier = require('html-minifier').minify beforeEach(() => { - hexo.config.minify.html = htmlDefault + hexo.config.minify.html = Object.assign({}, htmlDefault) }) test('default', () => { @@ -22,6 +22,15 @@ describe('html', () => { expect(result).toBe(expected) }) + test('disable', () => { + hexo.config.minify.html.enable = false + + const input = '

foo

' + const result = h(input, { path: '' }) + + expect(result).toBeUndefined() + }) + test('option', () => { const customOpt = { removeEmptyAttributes: false } hexo.config.minify.html = customOpt @@ -97,7 +106,7 @@ describe('css', () => { const CleanCSS = require('clean-css') beforeEach(() => { - hexo.config.minify.css = cssDefault + hexo.config.minify.css = Object.assign({}, cssDefault) }) test('default', async () => { @@ -107,6 +116,13 @@ describe('css', () => { expect(result).toBe(styles) }) + test('disable', async () => { + hexo.config.minify.css.enable = false + const input = 'foo { bar: baz; } foo { aaa: bbb; }' + const result = await c(input, { path: '' }) + expect(result).toBeUndefined() + }) + test('option', async () => { const customOpt = { level: { @@ -152,7 +168,7 @@ describe('js', () => { const Terser = require('terser') beforeEach(() => { - hexo.config.minify.js = jsDefault + hexo.config.minify.js = Object.assign({}, jsDefault) }) test('default', () => { @@ -162,6 +178,15 @@ describe('js', () => { expect(result).toBe(code) }) + test('disable', () => { + hexo.config.minify.js.enable = false + + const input = 'var o = { "foo": 1, bar: 3 };' + const result = j(input, { path: '' }) + + expect(result).toBeUndefined() + }) + test('option', () => { const customOpt = { mangle: {