You've already forked tf2wikipricing
test: add localization tests
This commit is contained in:
23
__tests__/localization.test.ts
Normal file
23
__tests__/localization.test.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { describe, it, expect, jest, beforeEach } from "bun:test";
|
||||||
|
import { extractLocaleFromURL } from '../src/content/utils/localization'
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('localization', () => {
|
||||||
|
it('should assume `en` if no locale is specified', async () => {
|
||||||
|
// extractLocaleFromURL('https://wiki.teamfortress.com/wiki/Team_Fortress_2') should return 'en'
|
||||||
|
expect(extractLocaleFromURL('https://wiki.teamfortress.com/wiki/Team_Fortress_2')).toBe('en')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should extract locale shortcode from URL correctly', async () => {
|
||||||
|
// extractLocaleFromURL('https://wiki.teamfortress.com/wiki/Phlogistinator/de') should return 'de'
|
||||||
|
expect(extractLocaleFromURL('https://wiki.teamfortress.com/wiki/Phlogistinator/de')).toBe('de')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should extract locale shortcode with special characters from URL correctly', async () => {
|
||||||
|
// extractLocaleFromURL('https://wiki.teamfortress.com/wiki/%C3%9CberCharge/zh-hans') should return 'zh-hans'
|
||||||
|
expect(extractLocaleFromURL('https://wiki.teamfortress.com/wiki/%C3%9CberCharge/zh-hans')).toBe('zh-hans')
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user