diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b82f3d4..f815478 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,18 @@ on: [push] jobs: + test: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - name: Set up mira + run: | + sudo apt-get -y install librime1t64 librime-plugin-lua libyaml-cpp0.8 + wget https://github.com/rimeinn/mira/releases/download/latest/mira + chmod +x mira + - name: Test + run: | + ./mira -C mira-cache tests/moran.test.yaml + simplified-moran: runs-on: ubuntu-latest steps: diff --git a/tests/moran.test.yaml b/tests/moran.test.yaml new file mode 100644 index 0000000..493a165 --- /dev/null +++ b/tests/moran.test.yaml @@ -0,0 +1,82 @@ +schema: moran +source_dir: .. +deploy: + # 出廠設置 + default: + tests: + - send: l + assert: cand[1].text == "了" and cand[1].comment == "⚡️" + - send: le + assert: cand[1].text == "樂" and cand[1].comment == "⚡️" + - send: lem + assert: cand[1].text == "樂" and cand[1].comment == "⚡️" + - send: lemd + assert: cand[1].text == "楽" and cand[1].comment == "" + - send: hello # 英語混輸 + assert: cand[1].text == "hello" + - send: jis + assert: cand[1].text == "級" and cand[1].comment == "⚡️" + - send: jisjo # 出簡讓全 + assert: cand[1].text == "紀" + + # 顏文字,測試 has_emoji 規則 + emoji: + options: + emoji: true + tests: + - send: hk + assert: cand[2].text == "👌" + - send: o + assert: cand[2].text == "😯" + - send: ou + assert: cand[2].text == "€" + - send: mzgo + assert: cand[2].text == "🇺🇸" + - send: vsgo + assert: cand[2].text == "🇨🇳" + + # 自定義簡快碼 + quick_code_indicator_empty: + patch: + moran/quick_code_indicator: "" + tests: + - send: l + assert: cand[1].text == "了" and cand[1].comment == "" + quick_code_indicator_other: + patch: + moran/quick_code_indicator: "💥" + tests: + - send: l + assert: cand[1].text == "了" and cand[1].comment == "💥" + - send: le + assert: cand[1].text == "樂" and cand[1].comment == "💥" + - send: lem + assert: cand[1].text == "樂" and cand[1].comment == "💥" + - send: lemd + assert: cand[1].text == "楽" and cand[1].comment == "" + + # 詞輔 + word_filter: + patch: + moran/enable_word_filter: true + tests: + - send: lmjx + assert: cand[1].text == "鏈接" + - send: lmjxz + assert: cand[1].text == "連接" + + # pin + pin: + options: + emoji: false + tests: + - send: 'lmjx' + assert: cand[1].text == '鏈接' and cand[2].text == '連接' + - send: 'lmjx{Control+t}' # SIDE-EFFECT!! + assert: cand[1].comment == "📌" + - send: 'lmjx{Control+t}' + assert: cand[1].comment == "" + - send: 'lmjx{Down}{Control+t}' + assert: cand[1].text == '連接' and cand[1].comment == "📌" + - send: 'lmjx' + assert: cand[1].text == '連接' and cand[1].comment == "📌"