mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Changed the uniqueSlug setting to include the deutsch locale to properly handle umlauts and tests.
This commit is contained in:
parent
fcf6b95121
commit
e22e15bc77
@ -2,6 +2,7 @@ import slugify from 'slug'
|
||||
export default async function uniqueSlug(string, isUnique) {
|
||||
const slug = slugify(string || 'anonymous', {
|
||||
lower: true,
|
||||
locale: 'de',
|
||||
})
|
||||
if (await isUnique(slug)) return slug
|
||||
|
||||
|
||||
@ -19,3 +19,17 @@ describe('uniqueSlug', () => {
|
||||
expect(uniqueSlug(string, isUnique)).resolves.toEqual('anonymous')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Slug is transliterated correctly', () => {
|
||||
it('Converts umlaut to two letter equivalent', () => {
|
||||
const umlaut = 'ä';
|
||||
const isUnique = jest.fn().mockResolvedValue(true)
|
||||
expect(uniqueSlug(string, isUnique)).resolves.toEqual('ae');
|
||||
})
|
||||
|
||||
it('Removes Spanish enya ', () => {
|
||||
const enya = 'ñ';
|
||||
const isUnique = jest.fn().mockResolvedValue(true)
|
||||
expect(uniqueSlug(string, isUnique)).resolves.toEqual('n');
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user