mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
A charmap added for slug to transliterate the german umlauts and the spanish enya. The package was updated but does not accept the setting properly.
This commit is contained in:
parent
9d19eab35b
commit
4c8eeb506e
@ -2,7 +2,7 @@ import slugify from 'slug'
|
||||
export default async function uniqueSlug(string, isUnique) {
|
||||
const slug = slugify(string || 'anonymous', {
|
||||
lower: true,
|
||||
locale: 'de',
|
||||
charmap: { Ä: 'AE', ä: 'ae', Ö: 'OE', ö: 'oe', Ü: 'UE', ü: 'ue', ñ: 'n' },
|
||||
})
|
||||
if (await isUnique(slug)) return slug
|
||||
|
||||
|
||||
@ -18,18 +18,17 @@ describe('uniqueSlug', () => {
|
||||
const isUnique = jest.fn().mockResolvedValue(true)
|
||||
expect(uniqueSlug(string, isUnique)).resolves.toEqual('anonymous')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Slug is transliterated correctly', () => {
|
||||
it('Converts umlaut to a two letter equivalent', () => {
|
||||
|
||||
it('Converts umlaut to a two letter equivalent', async () => {
|
||||
const umlaut = 'ä'
|
||||
const isUnique = jest.fn().mockResolvedValue(true)
|
||||
expect(uniqueSlug(umlaut, isUnique)).resolves.toEqual('ae')
|
||||
await expect(uniqueSlug(umlaut, isUnique)).resolves.toEqual('ae')
|
||||
})
|
||||
|
||||
it('Removes Spanish enya ', () => {
|
||||
it('Removes Spanish enya ', async () => {
|
||||
const enya = 'ñ'
|
||||
const isUnique = jest.fn().mockResolvedValue(true)
|
||||
expect(uniqueSlug(enya, isUnique)).resolves.toEqual('n')
|
||||
await expect(uniqueSlug(enya, isUnique)).resolves.toEqual('n')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user