summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFerdinand Thiessen <rpm@fthiessen.de>2023-01-26 18:14:07 +0100
committerFerdinand Thiessen <rpm@fthiessen.de>2023-02-20 15:03:31 +0100
commitc97137e434e64024ca951052b848f76d173e6515 (patch)
tree884c36a6b46d0aed54d712e1af72487a4a53c0e6
parentcdc384834512a909cbc1b5f4e880b239e63029b9 (diff)
downloadnextcloud-server-c97137e434e64024ca951052b848f76d173e6515.tar.gz
nextcloud-server-c97137e434e64024ca951052b848f76d173e6515.zip
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 <rpm@fthiessen.de>
-rw-r--r--core/js/tests/specs/l10nSpec.js9
1 files 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(