1+ /**
2+ * Copyright © Magento, Inc. All rights reserved.
3+ * See COPYING.txt for license details.
4+ */
5+ define ( [
6+ 'jquery' ,
7+ 'mage/translate'
8+ ] , function ( $ ) {
9+ 'use strict' ;
10+
11+ describe ( 'Test for mage/translate jQuery plugin' , function ( ) {
12+ it ( 'works with one string as parameter' , function ( ) {
13+ $ . mage . translate . add ( 'Hello World!' ) ;
14+ expect ( 'Hello World!' ) . toEqual ( $ . mage . translate . translate ( 'Hello World!' ) ) ;
15+ } ) ;
16+ it ( 'works with one array as parameter' , function ( ) {
17+ $ . mage . translate . add ( [ 'Hello World!' , 'Bonjour tout le monde!' ] ) ;
18+ expect ( 'Hello World!' ) . toEqual ( $ . mage . translate . translate ( 'Hello World!' ) ) ;
19+ } ) ;
20+ it ( 'works with one object as parameter' , function ( ) {
21+ var translation = { 'Hello World!' : 'Bonjour tout le monde!' } ;
22+ $ . mage . translate . add ( translation ) ;
23+ expect ( translation [ 'Hello World!' ] ) . toEqual ( $ . mage . translate . translate ( 'Hello World!' ) ) ;
24+
25+ translation = {
26+ 'Hello World!' : 'Hallo Welt!' ,
27+ 'Some text with symbols!-+"%#*' : 'Ein Text mit Symbolen!-+"%#*'
28+ } ;
29+
30+ $ . mage . translate . add ( translation ) ;
31+ $ . each ( translation , function ( key ) {
32+ expect ( translation [ key ] ) . toEqual ( $ . mage . translate . translate ( key ) ) ;
33+ } ) ;
34+ } ) ;
35+ it ( 'works with two string as parameter' , function ( ) {
36+ $ . mage . translate . add ( 'Hello World!' , 'Bonjour tout le monde!' ) ;
37+ expect ( 'Bonjour tout le monde!' ) . toEqual ( $ . mage . translate . translate ( 'Hello World!' ) ) ;
38+ } ) ;
39+ it ( 'works with translation alias __' , function ( ) {
40+ $ . mage . translate . add ( 'Hello World!' ) ;
41+ expect ( 'Hello World!' ) . toEqual ( $ . mage . __ ( 'Hello World!' ) ) ;
42+ } ) ;
43+ } ) ;
44+
45+ } ) ;
0 commit comments