test(include): negation pattern and basename

This commit is contained in:
curbengh 2019-12-29 02:33:59 +00:00
parent 51ff9d953d
commit 1c530b7d44
No known key found for this signature in database
GPG Key ID: 21EA847C35D6E034
1 changed files with 192 additions and 0 deletions

View File

@ -606,6 +606,102 @@ describe('gzip', () => {
expect(result).toBeDefined()
})
test('include - basename + slash + basename enabled', async () => {
hexo.route.remove(path)
const paths = [
'lorem/ipsum/dolor.html',
'gravida/sociis/erat/ante.css',
'aptent/elementum.js',
'felis/blandit/cursus.svg'
]
hexo.config.minify.gzip.include = [
'*.html',
'**/sociis/**/*.css'
]
paths.forEach((inpath) => {
hexo.route.set(inpath, input)
})
await g()
const routeList = hexo.route.list()
const expected = [
'lorem/ipsum/dolor.html.gz',
'gravida/sociis/erat/ante.css.gz'
]
const notExpected = [
'aptent/elementum.js.gz',
'felis/blandit/cursus.svg.gz'
]
expect(routeList).toEqual(expect.arrayContaining(expected))
expect(routeList).toEqual(expect.not.arrayContaining(notExpected))
})
test('include - basename + slash + basename disabled', async () => {
hexo.route.remove(path)
const paths = [
'lorem/ipsum/dolor.html',
'gravida/sociis/erat/ante.css',
'aptent/elementum.js',
'felis/blandit/cursus.svg'
]
hexo.config.minify.gzip.include = [
'*.html',
'**/sociis/**/*.css'
]
hexo.config.minify.gzip.globOptions = {
basename: false
}
paths.forEach((inpath) => {
hexo.route.set(inpath, input)
})
await g()
const routeList = hexo.route.list()
const expected = [
'gravida/sociis/erat/ante.css.gz'
]
const notExpected = [
'lorem/ipsum/dolor.html.gz',
'aptent/elementum.js.gz',
'felis/blandit/cursus.svg.gz'
]
expect(routeList).toEqual(expect.arrayContaining(expected))
expect(routeList).toEqual(expect.not.arrayContaining(notExpected))
})
test('include - reverse pattern + basename disabled', async () => {
hexo.route.remove(path)
const paths = [
'lorem/ipsum/dolor.html',
'gravida/sociis/erat/ante.css',
'aptent/elementum.js',
'felis/blandit/cursus.svg'
]
hexo.config.minify.gzip.include = [
'!dolor.html'
]
hexo.config.minify.gzip.globOptions = {
basename: false
}
paths.forEach((inpath) => {
hexo.route.set(inpath, input)
})
await g()
const routeList = hexo.route.list()
const expected = paths.map((path) => path.concat('.gz'))
expect(routeList).toEqual(expect.arrayContaining(expected))
})
})
describe('brotli', () => {
@ -723,4 +819,100 @@ describe('brotli', () => {
expect(result).toBeDefined()
})
test('include - basename + slash + basename enabled', async () => {
hexo.route.remove(path)
const paths = [
'lorem/ipsum/dolor.html',
'gravida/sociis/erat/ante.css',
'aptent/elementum.js',
'felis/blandit/cursus.svg'
]
hexo.config.minify.brotli.include = [
'*.html',
'**/sociis/**/*.css'
]
paths.forEach((inpath) => {
hexo.route.set(inpath, input)
})
await b()
const routeList = hexo.route.list()
const expected = [
'lorem/ipsum/dolor.html.br',
'gravida/sociis/erat/ante.css.br'
]
const notExpected = [
'aptent/elementum.js.br',
'felis/blandit/cursus.svg.br'
]
expect(routeList).toEqual(expect.arrayContaining(expected))
expect(routeList).toEqual(expect.not.arrayContaining(notExpected))
})
test('include - basename + slash + basename disabled', async () => {
hexo.route.remove(path)
const paths = [
'lorem/ipsum/dolor.html',
'gravida/sociis/erat/ante.css',
'aptent/elementum.js',
'felis/blandit/cursus.svg'
]
hexo.config.minify.brotli.include = [
'*.html',
'**/sociis/**/*.css'
]
hexo.config.minify.brotli.globOptions = {
basename: false
}
paths.forEach((inpath) => {
hexo.route.set(inpath, input)
})
await b()
const routeList = hexo.route.list()
const expected = [
'gravida/sociis/erat/ante.css.br'
]
const notExpected = [
'lorem/ipsum/dolor.html.br',
'aptent/elementum.js.br',
'felis/blandit/cursus.svg.br'
]
expect(routeList).toEqual(expect.arrayContaining(expected))
expect(routeList).toEqual(expect.not.arrayContaining(notExpected))
})
test('include - reverse pattern + basename disabled', async () => {
hexo.route.remove(path)
const paths = [
'lorem/ipsum/dolor.html',
'gravida/sociis/erat/ante.css',
'aptent/elementum.js',
'felis/blandit/cursus.svg'
]
hexo.config.minify.brotli.include = [
'!dolor.html'
]
hexo.config.minify.brotli.globOptions = {
basename: false
}
paths.forEach((inpath) => {
hexo.route.set(inpath, input)
})
await b()
const routeList = hexo.route.list()
const expected = paths.map((path) => path.concat('.br'))
expect(routeList).toEqual(expect.arrayContaining(expected))
})
})