test: option.enable

This commit is contained in:
curbengh 2019-12-26 15:24:54 +00:00
parent 631503aa1a
commit f7c600545b
No known key found for this signature in database
GPG Key ID: 21EA847C35D6E034
1 changed files with 28 additions and 3 deletions

View File

@ -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 = '<p id="">foo</p>'
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: {