Skip to content

Commit ffeabde

Browse files
committed
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>
1 parent bd74188 commit ffeabde

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

core/js/tests/specs/l10nSpec.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ describe('OC.L10N tests', function() {
110110
});
111111
});
112112
describe('async loading of translations', function() {
113+
afterEach(() => {
114+
document.documentElement.removeAttribute('data-locale')
115+
})
113116
it('loads bundle for given app and calls callback', function(done) {
114-
var localeStub = sinon.stub(OC, 'getLocale').returns('zh_CN');
117+
document.documentElement.setAttribute('data-locale', 'zh_CN')
115118
var callbackStub = sinon.stub();
116119
var promiseStub = sinon.stub();
117120
var loading = OC.L10N.load(TEST_APP, callbackStub);
@@ -129,9 +132,9 @@ describe('OC.L10N tests', function() {
129132
expect(callbackStub.calledOnce).toEqual(true);
130133
expect(promiseStub.calledOnce).toEqual(true);
131134
expect(t(TEST_APP, 'Hello world!')).toEqual('你好世界!');
132-
localeStub.restore();
133135
})
134-
.then(done);
136+
.then(done)
137+
.catch(e => expect(e).toBe('No error expected!'));
135138

136139
expect(promiseStub.notCalled).toEqual(true);
137140
req.respond(

0 commit comments

Comments
 (0)