-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests and GitHub Actions integration
- Loading branch information
1 parent
f94e6bc
commit 7654514
Showing
7 changed files
with
3,792 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
coverage/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { apply, applyToWord, translitMap } from '../translit'; | ||
|
||
describe('translitMap', () => { | ||
it('should contain mapping for Cyrillic "а" and "А"', () => { | ||
expect(translitMap['а']).toBe('a'); | ||
expect(translitMap['А']).toBe('A'); | ||
}); | ||
}); | ||
|
||
describe('applyToWord', () => { | ||
it('should transliterate a word correctly', () => { | ||
expect(applyToWord('дӏахь')).toBe('djaẋ'); | ||
expect(applyToWord('доьгӏна')).toBe('döġna'); | ||
}); | ||
|
||
it('should handle words with special cases', () => { | ||
expect(applyToWord('тӏ')).toBe('ṫ'); | ||
expect(applyToWord('къ')).toBe('q̇'); | ||
}); | ||
|
||
it('should handle uppercase words correctly', () => { | ||
expect(applyToWord('Д')).toBe('D'); | ||
expect(applyToWord('Т')).toBe('T'); | ||
}); | ||
|
||
it('should handle mixed case words correctly', () => { | ||
expect(applyToWord('КъХ')).toBe('Q̇X'); | ||
}); | ||
|
||
it('should handle words with standalone Cyrillic "ъ"', () => { | ||
expect(applyToWord('къе')).toBe('q̇e'); | ||
expect(applyToWord('Къе')).toBe('Q̇e'); | ||
}); | ||
|
||
it('should handle words with Cyrillic "ъ" before "е", "ё", "ю", or "я"', () => { | ||
expect(applyToWord('къе')).toBe('q̇e'); | ||
expect(applyToWord('къё')).toBe('q̇ö'); | ||
expect(applyToWord('къю')).toBe('q̇yu'); | ||
expect(applyToWord('къя')).toBe('q̇ya'); | ||
expect(applyToWord('къЕ')).toBe('q̇E'); | ||
expect(applyToWord('къЁ')).toBe('q̇Ö'); | ||
expect(applyToWord('къЮ')).toBe('q̇Yu'); | ||
expect(applyToWord('къЯ')).toBe('q̇Ya'); | ||
}); | ||
|
||
it('should handle "ъ" not preceded by "к" correctly', () => { | ||
expect(applyToWord('ъе')).toBe('ye'); | ||
expect(applyToWord('Ъё')).toBe('ö'); | ||
expect(applyToWord('ъю')).toBe('yu'); | ||
expect(applyToWord('ъя')).toBe('ya'); | ||
}); | ||
|
||
it('should handle "ъ" preceded by a non-"к" character correctly', () => { | ||
expect(applyToWord('мъе')).toBe('mye'); | ||
expect(applyToWord('Мъё')).toBe('Mö'); | ||
expect(applyToWord('пъю')).toBe('pyu'); | ||
expect(applyToWord('съя')).toBe('sya'); | ||
}); | ||
|
||
it('should handle words with "е" at the start correctly', () => { | ||
expect(applyToWord('е')).toBe('ye'); | ||
expect(applyToWord('Е')).toBe('Ye'); | ||
}); | ||
|
||
it('should handle words with "н" at the end correctly', () => { | ||
expect(applyToWord('тхан')).toBe('txaŋ'); | ||
expect(applyToWord('тхаН')).toBe('txaŊ'); | ||
}); | ||
|
||
it('should handle words without any special transliteration cases', () => { | ||
expect(applyToWord('нанас')).toBe('nanas'); | ||
}); | ||
}); | ||
|
||
describe('apply', () => { | ||
it('should transliterate a text correctly', () => { | ||
const text = 'Мелхо а, шуна цхьанна а тхайх бала ца бархьама, дийнахь а, буса а, къа а хьоьгуш, болх бора оха.'; | ||
const expected = 'Melxo ə, şuna cẋanna ə txayx bala ca barẋama, diynaẋ ə, busa ə, q̇a ə ẋöguş, bolx bora oxa.'; | ||
expect(apply(text)).toBe(expected); | ||
}); | ||
|
||
it('should replace standalone Cyrillic "а" with "ə"', () => { | ||
expect(apply('дӏахь а доьгӏна')).toBe('djaẋ ə döġna'); | ||
}); | ||
|
||
it('should handle mixed case texts correctly', () => { | ||
expect(apply('Дӏахь А доьгӏна')).toBe('Djaẋ A döġna'); | ||
}); | ||
|
||
it('should handle texts with punctuation', () => { | ||
expect(apply('а, а. а!')).toBe('ə, ə. ə!'); | ||
}); | ||
|
||
it('should handle texts with hyphens correctly', () => { | ||
expect(apply('доьгӏна-шун')).toBe('döġna-şuŋ'); | ||
}); | ||
|
||
it('should handle empty strings', () => { | ||
expect(apply('')).toBe(''); | ||
}); | ||
|
||
it('should handle texts with no Cyrillic characters', () => { | ||
expect(apply('Hello world!')).toBe('Hello world!'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testPathIgnorePatterns: ['/node_modules/'], | ||
coverageThreshold: { | ||
global: { | ||
branches: 90, | ||
functions: 90, | ||
lines: 90, | ||
statements: 90, | ||
}, | ||
}, | ||
}; |
Oops, something went wrong.