mirror of https://github.com/msgbyte/tailchat
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
4 years ago
|
import { parsePluginManifest } from '../utils';
|
||
|
|
||
|
describe('parsePluginManifest', () => {
|
||
|
test.each([
|
||
|
[
|
||
|
'correct',
|
||
|
JSON.stringify({
|
||
|
label: '网页面板插件',
|
||
|
name: 'com.msgbyte.webview',
|
||
|
url: '/plugins/com.msgbyte.webview/index.js',
|
||
|
version: '0.0.0',
|
||
|
author: 'msgbyte',
|
||
|
description: '为群组提供创建网页面板的功能',
|
||
|
requireRestart: false,
|
||
|
}),
|
||
|
true,
|
||
|
],
|
||
|
['string', 'foo.bar', false],
|
||
|
[
|
||
|
'no used properties',
|
||
|
JSON.stringify({
|
||
|
label: '网页面板插件',
|
||
|
foo: 'bar',
|
||
|
}),
|
||
|
false,
|
||
|
],
|
||
|
[
|
||
4 years ago
|
'not allow additional properties',
|
||
4 years ago
|
JSON.stringify({
|
||
|
label: '网页面板插件',
|
||
|
name: 'com.msgbyte.webview',
|
||
|
url: '/plugins/com.msgbyte.webview/index.js',
|
||
|
version: '0.0.0',
|
||
|
author: 'msgbyte',
|
||
|
description: '为群组提供创建网页面板的功能',
|
||
|
requireRestart: false,
|
||
|
foo: 'bar',
|
||
|
}),
|
||
4 years ago
|
false,
|
||
4 years ago
|
],
|
||
|
[
|
||
|
'missed properties',
|
||
|
JSON.stringify({
|
||
|
label: '网页面板插件',
|
||
|
}),
|
||
|
false,
|
||
|
],
|
||
|
])('case: %# %s', (title, input, valid) => {
|
||
|
if (valid === true) {
|
||
|
expect(parsePluginManifest(input)).toEqual(JSON.parse(input));
|
||
|
} else {
|
||
|
expect(() => parsePluginManifest(input)).toThrowError();
|
||
|
}
|
||
|
});
|
||
|
});
|