test: add more case and fix error case

for parsePluginManifest and workboxPluginPattern
pull/81/head
moonrailgun 3 years ago
parent 980775f020
commit 1335729887

@ -2,12 +2,16 @@ import { workboxPluginPattern } from '../utils';
describe('workboxPluginPattern', () => { describe('workboxPluginPattern', () => {
test.each([ test.each([
// 缓存case
['/plugins/com.msgbyte.foo/bar.js', true], ['/plugins/com.msgbyte.foo/bar.js', true],
['/plugins/com.msgbyte.foo.foz/bar.js', true], ['/plugins/com.msgbyte.foo.foz/bar.js', true],
// 不缓存case
['/plugins/com.msgbyte.foo/index.js', false], ['/plugins/com.msgbyte.foo/index.js', false],
['/plugins/com.msgbyte.foo/index-abcde.js', false], // TODO: 这个期望是true的。但是不会写正则 ['/plugins/com.msgbyte.foo/index-abcde.js', false], // TODO: 这个期望是true的。但是不会写正则
['/plugins/com.msgbyte.foo/index.woff', false], ['/plugins/com.msgbyte.foo/index.woff', false],
['/plugins/com.msgbyte.foo/font.woff', false], ['/plugins/com.msgbyte.foo/font.woff', false],
['/plugins/a/b/c/d/e/f/g.js', false],
])('%s: %p', (input, output) => { ])('%s: %p', (input, output) => {
expect(workboxPluginPattern.test(input)).toBe(output); expect(workboxPluginPattern.test(input)).toBe(output);
}); });

@ -25,7 +25,7 @@ describe('parsePluginManifest', () => {
false, false,
], ],
[ [
'more properties', 'not allow additional properties',
JSON.stringify({ JSON.stringify({
label: '网页面板插件', label: '网页面板插件',
name: 'com.msgbyte.webview', name: 'com.msgbyte.webview',
@ -36,7 +36,7 @@ describe('parsePluginManifest', () => {
requireRestart: false, requireRestart: false,
foo: 'bar', foo: 'bar',
}), }),
true, false,
], ],
[ [
'missed properties', 'missed properties',

Loading…
Cancel
Save