From c97137e434e64024ca951052b848f76d173e6515 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 26 Jan 2023 18:14:07 +0100 Subject: [PATCH] fix(jsunit): Modify `OC.L10N` tests as it does not depend on `OC.` anymore Meaning we can not stub `getLocale` but must override the document attribute instead. Signed-off-by: Ferdinand Thiessen --- core/js/tests/specs/l10nSpec.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/js/tests/specs/l10nSpec.js b/core/js/tests/specs/l10nSpec.js index 18c1adabea1..eaa9f5744c2 100644 --- a/core/js/tests/specs/l10nSpec.js +++ b/core/js/tests/specs/l10nSpec.js @@ -110,8 +110,11 @@ describe('OC.L10N tests', function() { }); }); describe('async loading of translations', function() { + afterEach(() => { + document.documentElement.removeAttribute('data-locale') + }) it('loads bundle for given app and calls callback', function(done) { - var localeStub = sinon.stub(OC, 'getLocale').returns('zh_CN'); + document.documentElement.setAttribute('data-locale', 'zh_CN') var callbackStub = sinon.stub(); var promiseStub = sinon.stub(); var loading = OC.L10N.load(TEST_APP, callbackStub); @@ -129,9 +132,9 @@ describe('OC.L10N tests', function() { expect(callbackStub.calledOnce).toEqual(true); expect(promiseStub.calledOnce).toEqual(true); expect(t(TEST_APP, 'Hello world!')).toEqual('你好世界!'); - localeStub.restore(); }) - .then(done); + .then(done) + .catch(e => expect(e).toBe('No error expected!')); expect(promiseStub.notCalled).toEqual(true); req.respond(