From fe190b6fe5facf50ae8a0b5c21eda02a3e21b68e Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Thu, 13 Jul 2023 00:32:29 -0400 Subject: [PATCH] 0.1.3: fix emoji --- package.json | 2 +- src/loader.ts | 3 ++- test/test-loader.spec.ts | 16 ++++++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 10cbdd5..9594fea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@libreservice/micro-plum", - "version": "0.1.2", + "version": "0.1.3", "main": "dist/index.js", "type": "module", "files": [ diff --git a/src/loader.ts b/src/loader.ts index d33d5bb..a314cce 100644 --- a/src/loader.ts +++ b/src/loader.ts @@ -137,7 +137,8 @@ class Recipe { } async loadFile (file: string) { - if (file === 'opencc/emoji.json') { + // Don't download emoji.json from current repo, unless this is the emoji repo + if (file === 'opencc/emoji.json' && this.repo !== 'rime/rime-emoji') { return } if (file in this.loadedFiles) { diff --git a/test/test-loader.spec.ts b/test/test-loader.spec.ts index 81a3cf3..c5732c4 100644 --- a/test/test-loader.spec.ts +++ b/test/test-loader.spec.ts @@ -105,13 +105,17 @@ it('CDN prefix', () => { } }) +const genericRecipeTestCases = { + essay: ['essay.txt'], + emoji: ['emoji_suggestion.yaml', 'opencc/emoji.json'] +} + it('Load generic recipe', async () => { - const recipe = new Recipe('essay') - const result = await recipe.load() - expect(result).toEqual([{ - file: 'essay.txt', - content: undefined - }]) + for (const [target, files] of Object.entries(genericRecipeTestCases)) { + const recipe = new Recipe(target) + const result = await recipe.load() + expect(result.map(item => item.file).sort()).toEqual(files) + } }) it('Load recipe', async () => {