Skip to content

Commit 7dcc5f9

Browse files
committed
✅ 通过单元测试
1 parent 30db447 commit 7dcc5f9

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/pkg/utils/script.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ describe("getUserConfigStr", () => {
264264
config:
265265
name: 配置名称
266266
value: 123
267-
==UserConfig== */
267+
==/UserConfig== */
268268
269269
console.log('Hello World');
270270
`;
@@ -274,7 +274,7 @@ console.log('Hello World');
274274
config:
275275
name: 配置名称
276276
value: 123
277-
==UserConfig== */`);
277+
==/UserConfig== */`);
278278
});
279279

280280
test("没有UserConfig标签应返回null", () => {
@@ -302,7 +302,7 @@ describe("parseUserConfig", () => {
302302
name: 测试配置
303303
value: 123
304304
enabled: true
305-
==UserConfig== */
305+
==/UserConfig== */
306306
307307
console.log('Hello World');
308308
`;
@@ -324,7 +324,7 @@ value: 123
324324
name: 配置2
325325
value: 456
326326
enabled: true
327-
==UserConfig== */
327+
==/UserConfig== */
328328
329329
console.log('Hello World');
330330
`;
@@ -346,7 +346,7 @@ console.log('Hello World');
346346
test("解析空的UserConfig", () => {
347347
const code = `
348348
/* ==UserConfig==
349-
==UserConfig== */
349+
==/UserConfig== */
350350
351351
console.log('Hello World');
352352
`;

src/pkg/utils/script.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function parseUserConfig(code: string): UserConfig | undefined {
8787
const ret: UserConfig = {};
8888
configs.forEach((val) => {
8989
const obj: UserConfig = YAML.parse(val);
90-
Object.keys(obj).forEach((key) => {
90+
Object.keys(obj || {}).forEach((key) => {
9191
ret[key] = obj[key];
9292
});
9393
});

0 commit comments

Comments
 (0)