|
|
|
@ -28,6 +28,7 @@ describe('LocalizationService', () => { |
|
|
|
provide: ConfigStateService, |
|
|
|
useValue: { |
|
|
|
getOne: vi.fn(), |
|
|
|
getAll: vi.fn(() => ({})), |
|
|
|
refreshAppState: vi.fn(), |
|
|
|
getDeep: vi.fn(), |
|
|
|
getDeep$: vi.fn(() => new Subject()), |
|
|
|
@ -70,4 +71,28 @@ describe('LocalizationService', () => { |
|
|
|
expect(result).toBeDefined(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('#instant (missing :: separator)', () => { |
|
|
|
const separatorWarning = 'The localization source separator (::) not found.'; |
|
|
|
|
|
|
|
it('should not warn for a plain string used as a passthrough value', () => { |
|
|
|
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => undefined); |
|
|
|
|
|
|
|
const result = service.instant('Plain text'); |
|
|
|
|
|
|
|
expect(result).toBe('Plain text'); |
|
|
|
expect(warnSpy).not.toHaveBeenCalledWith(separatorWarning); |
|
|
|
warnSpy.mockRestore(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should return the default value without warning', () => { |
|
|
|
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => undefined); |
|
|
|
|
|
|
|
const result = service.instant({ key: 'Plain text', defaultValue: 'Fallback' }); |
|
|
|
|
|
|
|
expect(result).toBe('Fallback'); |
|
|
|
expect(warnSpy).not.toHaveBeenCalledWith(separatorWarning); |
|
|
|
warnSpy.mockRestore(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|