Skip to content

Commit

Permalink
ci: 單元測試
Browse files Browse the repository at this point in the history
  • Loading branch information
ksqsf committed Dec 15, 2024
1 parent 82949a9 commit 77bd954
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
82 changes: 82 additions & 0 deletions tests/moran.test.yaml
Original file line number Diff line number Diff line change
@@ -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 == "📌"

0 comments on commit 77bd954

Please sign in to comment.