-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathhelpers.spec.js
More file actions
36 lines (30 loc) · 1 KB
/
helpers.spec.js
File metadata and controls
36 lines (30 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { tMock } from 'jestLib/I18n'
import { extend as extendI18n } from 'twake-i18n'
import { getTranslatedManifestProperty } from './helpers'
describe('getTranslatedManifestProperty helper', () => {
const appMock = {
slug: 'mock',
name: 'Not Translated Name',
description: 'not translated description'
}
const translatedName = 'Translated Name'
beforeAll(() => {
extendI18n({
[`apps.${appMock.slug}.name`]: translatedName
})
})
it('should return the translated property if translated', () => {
// name is translated here in the beforeAll
expect(getTranslatedManifestProperty(appMock, 'name', tMock)).toBe(
translatedName
)
})
it('should fallback to the manifest property if no translated property found', () => {
expect(getTranslatedManifestProperty(appMock, 'description', tMock)).toBe(
appMock.description
)
})
it('should always return an default empty string value', () => {
expect(getTranslatedManifestProperty()).toBe('')
})
})