From 1335729887a29c1e7a92d9e3606cf3f886cfdf07 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Mon, 22 Nov 2021 16:46:02 +0800 Subject: [PATCH] test: add more case and fix error case for parsePluginManifest and workboxPluginPattern --- web/build/__tests__/utils.spec.ts | 4 ++++ web/src/plugin/__tests__/utils.spec.ts | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/web/build/__tests__/utils.spec.ts b/web/build/__tests__/utils.spec.ts index 39070116..f6c7636c 100644 --- a/web/build/__tests__/utils.spec.ts +++ b/web/build/__tests__/utils.spec.ts @@ -2,12 +2,16 @@ import { workboxPluginPattern } from '../utils'; describe('workboxPluginPattern', () => { test.each([ + // 缓存case ['/plugins/com.msgbyte.foo/bar.js', true], ['/plugins/com.msgbyte.foo.foz/bar.js', true], + + // 不缓存case ['/plugins/com.msgbyte.foo/index.js', false], ['/plugins/com.msgbyte.foo/index-abcde.js', false], // TODO: 这个期望是true的。但是不会写正则 ['/plugins/com.msgbyte.foo/index.woff', false], ['/plugins/com.msgbyte.foo/font.woff', false], + ['/plugins/a/b/c/d/e/f/g.js', false], ])('%s: %p', (input, output) => { expect(workboxPluginPattern.test(input)).toBe(output); }); diff --git a/web/src/plugin/__tests__/utils.spec.ts b/web/src/plugin/__tests__/utils.spec.ts index 8fed4694..de4debb8 100644 --- a/web/src/plugin/__tests__/utils.spec.ts +++ b/web/src/plugin/__tests__/utils.spec.ts @@ -25,7 +25,7 @@ describe('parsePluginManifest', () => { false, ], [ - 'more properties', + 'not allow additional properties', JSON.stringify({ label: '网页面板插件', name: 'com.msgbyte.webview', @@ -36,7 +36,7 @@ describe('parsePluginManifest', () => { requireRestart: false, foo: 'bar', }), - true, + false, ], [ 'missed properties',