@@ -110,67 +110,4 @@ describe('OC.L10N tests', function() {
110110 checkPlurals ( ) ;
111111 } ) ;
112112 } ) ;
113- describe ( 'async loading of translations' , function ( ) {
114- afterEach ( ( ) => {
115- document . documentElement . removeAttribute ( 'data-locale' )
116- } )
117- it ( 'loads bundle for given app and calls callback' , function ( done ) {
118- document . documentElement . setAttribute ( 'data-locale' , 'zh_CN' )
119- var callbackStub = sinon . stub ( ) ;
120- var promiseStub = sinon . stub ( ) ;
121- var loading = OC . L10N . load ( TEST_APP , callbackStub ) ;
122- expect ( callbackStub . notCalled ) . toEqual ( true ) ;
123- var req = fakeServer . requests [ 0 ] ;
124-
125- console . warn ( 'fff-' , window . OC . appswebroots )
126- loading
127- . then ( promiseStub )
128- . then ( function ( ) {
129- expect ( fakeServer . requests . length ) . toEqual ( 1 ) ;
130- expect ( req . url ) . toEqual (
131- OC . getRootPath ( ) + '/apps3/' + TEST_APP + '/l10n/zh_CN.json'
132- ) ;
133-
134- expect ( callbackStub . calledOnce ) . toEqual ( true ) ;
135- expect ( promiseStub . calledOnce ) . toEqual ( true ) ;
136- expect ( t ( TEST_APP , 'Hello world!' ) ) . toEqual ( '你好世界!' ) ;
137- } )
138- . then ( done )
139- . catch ( e => expect ( e ) . toBe ( 'No error expected!' ) ) ;
140-
141- expect ( promiseStub . notCalled ) . toEqual ( true ) ;
142- req . respond (
143- 200 ,
144- { 'Content-Type' : 'application/json' } ,
145- JSON . stringify ( {
146- translations : { 'Hello world!' : '你好世界!' } ,
147- pluralForm : 'nplurals=2; plural=(n != 1);'
148- } )
149- ) ;
150- } ) ;
151- it ( 'calls callback if translation already available' , function ( done ) {
152- var callbackStub = sinon . stub ( ) ;
153- spyOn ( console , 'warn' ) ;
154- OC . L10N . register ( TEST_APP , {
155- 'Hello world!' : 'Hallo Welt!'
156- } ) ;
157- OC . L10N . load ( TEST_APP , callbackStub )
158- . then ( function ( ) {
159- expect ( callbackStub . calledOnce ) . toEqual ( true ) ;
160- expect ( fakeServer . requests . length ) . toEqual ( 0 ) ;
161- } )
162- . then ( done ) ;
163-
164- } ) ;
165- it ( 'calls callback if locale is en' , function ( done ) {
166- var callbackStub = sinon . stub ( ) ;
167- OC . L10N . load ( TEST_APP , callbackStub )
168- . then ( function ( ) {
169- expect ( callbackStub . calledOnce ) . toEqual ( true ) ;
170- expect ( fakeServer . requests . length ) . toEqual ( 0 ) ;
171- } )
172- . then ( done )
173- . catch ( done ) ;
174- } ) ;
175- } ) ;
176113} ) ;
0 commit comments