From 88545b9f9582767d12e21e2b23cdf9135ddbbd2a Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Tue, 9 Apr 2024 09:59:38 +0200 Subject: [PATCH] add tests --- .../localization.controller.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/libs/localization-api/localization.controller.test.ts b/src/Umbraco.Web.UI.Client/src/libs/localization-api/localization.controller.test.ts index c9b1ab775a..e85968960f 100644 --- a/src/Umbraco.Web.UI.Client/src/libs/localization-api/localization.controller.test.ts +++ b/src/Umbraco.Web.UI.Client/src/libs/localization-api/localization.controller.test.ts @@ -274,6 +274,22 @@ describe('UmbLocalizeController', () => { }); }); + describe('string', () => { + it('should replace words prefixed with a # with translated value', async () => { + const str = '#close'; + const str2 = '#logout #close'; + const str3 = '#logout #missing_translation_key #close'; + expect(controller.string(str)).to.equal('Close'); + expect(controller.string(str2)).to.equal('Log out Close'); + expect(controller.string(str3)).to.equal('Log out #missing_translation_key Close'); + }); + + it('should return the word with a # if the word is not found', async () => { + const str = '#missing_translation_key'; + expect(controller.string(str)).to.equal('#missing_translation_key'); + }); + }); + describe('host element', () => { let element: UmbLocalizeControllerHostElement;