26 lines
1.4 KiB
TypeScript
26 lines
1.4 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { fixKeyboardLayout } from '../src/gateway/chat/hangul-layout';
|
|
|
|
test('영문 모드로 친 한글을 되돌린다', () => {
|
|
assert.equal(fixKeyboardLayout('dkssudgktpdy')?.text, '안녕하세요');
|
|
assert.equal(fixKeyboardLayout('rnal skfTl')?.text, '구미 날씨');
|
|
assert.equal(fixKeyboardLayout('rnal skfTl?')?.text, '구미 날씨?');
|
|
assert.equal(fixKeyboardLayout('rnal skfTl')?.kind, 'en2ko');
|
|
});
|
|
test('겹받침·겹모음·쌍자음', () => {
|
|
assert.equal(fixKeyboardLayout('rkqt dlTek')?.text, '값 있다');
|
|
assert.equal(fixKeyboardLayout('dhkTsk')?.text, '왔나');
|
|
});
|
|
test('영어 문장은 건드리지 않는다', () => {
|
|
for (const s of ['what is the weather', 'hello there', 'dog', 'how are you', 'test code', 'thanks a lot']) assert.equal(fixKeyboardLayout(s), null, s);
|
|
});
|
|
test('URL·숫자·코드·정상 한글은 그대로', () => {
|
|
for (const s of ['https://example.com', 'abc123', 'ㅋㅋㅋ', '안녕하세요', '오늘 날씨', 'ㅇㅇ 알겠어', 'ㅠㅠ']) assert.equal(fixKeyboardLayout(s), null, s);
|
|
});
|
|
test('한글 모드로 친 영어를 되돌린다', () => {
|
|
assert.equal(fixKeyboardLayout('ㅗ디ㅣㅐ')?.text, 'hello');
|
|
assert.equal(fixKeyboardLayout('ㅗㅐㅈ ㅁㄱㄷ ㅛㅐㅕ')?.text, 'how are you');
|
|
assert.equal(fixKeyboardLayout('ㅗ디ㅣㅐ')?.kind, 'ko2en');
|
|
});
|