Skip to content

Commit

Permalink
chore: add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Bas950 committed Aug 28, 2024
1 parent 3cefff2 commit b2cd580
Show file tree
Hide file tree
Showing 3 changed files with 3,564 additions and 5 deletions.
28 changes: 24 additions & 4 deletions packages/romanize-thai/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
import { describe, it } from 'vitest'
import { THAI_REGEX, failingTests, successTests } from './mocks/testData.js'

import { romanize } from './index.js'

describe('romanize-thai', () => {
it('should romanize thai text', () => {
// test code here
it('should romanize thai text', async ({ expect }) => {
for (const { input, romanized } of successTests) {
const result = romanize(input)
expect(result).not.toMatch(THAI_REGEX)
expect(result).toBe(romanized)
}

for (const { input } of failingTests) {
const result = romanize(input)
if (result.match(THAI_REGEX)) {
expect.fail(`Expected ${input} to be romanized but got ${result}`)

Check failure on line 17 in packages/romanize-thai/src/index.test.ts

View workflow job for this annotation

GitHub Actions / test

src/index.test.ts > romanize-thai > should romanize thai text

AssertionError: Expected วิบวูบ to be romanized but got wibuaูb ❯ src/index.test.ts:17:16
}
}
})

it('should not romanize non-thai text', () => {
// test code here
it('should not romanize non-thai text', ({ expect }) => {
expect(romanize('hello')).toBe('hello')
expect(romanize('123')).toBe('123')
expect(romanize('!@#$%^&*()')).toBe('!@#$%^&*()')
//* Shouldn't romanize different languages (e.g. Japanese, Chinese, Korean)
expect(romanize('こんにちは')).toBe('こんにちは')
expect(romanize('你好')).toBe('你好')
expect(romanize('안녕하세요')).toBe('안녕하세요')
})
})
Loading

0 comments on commit b2cd580

Please sign in to comment.