Skip to content

Commit 323603c

Browse files
committed
Adds tests for translation payload override
1 parent cd352d0 commit 323603c

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

spec/PushWorker.spec.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,75 @@ describe('PushWorker', () => {
220220
}
221221
});
222222
});
223+
224+
it('should propely override alert-lang with translations', () => {
225+
const bodies = PushUtils.bodiesPerLocales({
226+
data: {
227+
alert: 'Yo!',
228+
badge: 'Increment',
229+
'alert-fr': 'Yolo!',
230+
},
231+
translation: {
232+
'fr': { alert: 'frenchy!', title: 'yolo' },
233+
'en': { alert: 'english', badge: 2, other: 'value' },
234+
}
235+
}, ['fr', 'en']);
236+
expect(bodies).toEqual({
237+
fr: {
238+
data: {
239+
alert: 'frenchy!',
240+
title: 'yolo',
241+
}
242+
},
243+
en: {
244+
data: {
245+
alert: 'english',
246+
badge: 2,
247+
other: 'value'
248+
}
249+
},
250+
default: {
251+
data: {
252+
alert: 'Yo!',
253+
badge: 'Increment',
254+
}
255+
}
256+
});
257+
});
258+
259+
it('should propely override alert-lang with translations strings', () => {
260+
const bodies = PushUtils.bodiesPerLocales({
261+
data: {
262+
alert: 'Yo!',
263+
badge: 'Increment',
264+
'alert-fr': 'Yolo!',
265+
'alert-en': 'Yolo!'
266+
},
267+
translation: {
268+
'fr': 'frenchy',
269+
}
270+
}, ['fr', 'en']);
271+
expect(bodies).toEqual({
272+
fr: {
273+
data: {
274+
alert: 'frenchy',
275+
badge: 'Increment',
276+
}
277+
},
278+
en: {
279+
data: {
280+
alert: 'Yolo!',
281+
badge: 'Increment'
282+
}
283+
},
284+
default: {
285+
data: {
286+
alert: 'Yo!',
287+
badge: 'Increment',
288+
}
289+
}
290+
});
291+
});
223292
});
224293

225294
describe('pushStatus', () => {

0 commit comments

Comments
 (0)