Skip to content

Commit

Permalink
fix(jsunit): Modify OC.L10N tests as it does not depend on OC. an…
Browse files Browse the repository at this point in the history
…ymore

Meaning we can not stub `getLocale` but must override the document attribute instead.

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
  • Loading branch information
susnux committed Feb 20, 2023
1 parent cdc3848 commit c97137e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/js/tests/specs/l10nSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
Expand Down

0 comments on commit c97137e

Please sign in to comment.