@@ -479,27 +479,62 @@ function testStart() {
479
479
480
480
481
481
function testSetLang ( ) {
482
- createAndInstallTestInstances ( ) ;
483
482
testStubs . replace ( goog , 'LOCALE' , 'de' ) ;
483
+ // Language code of auth instance is set to goog.LOCALE at initialization.
484
+ // Replace goog.LOCALE and then install instance.
485
+ createAndInstallTestInstances ( ) ;
484
486
app1 . start ( container1 , config1 ) ;
485
487
assertEquals ( 'de' , container1 . getAttribute ( 'lang' ) ) ;
488
+ assertEquals ( 'de' , app1 . getAuth ( ) . languageCode ) ;
489
+ assertEquals ( 'de' , app1 . getExternalAuth ( ) . languageCode ) ;
486
490
app1 . reset ( ) ;
487
491
assertFalse ( container1 . hasAttribute ( 'lang' ) ) ;
492
+ }
488
493
494
+ function testSetLang_codeWithdash ( ) {
489
495
testStubs . replace ( goog , 'LOCALE' , 'zh-CN' ) ;
496
+ // Language code of auth instance is set to goog.LOCALE at initialization.
497
+ // Replace goog.LOCALE and then install instance.
498
+ createAndInstallTestInstances ( ) ;
490
499
app1 . start ( container1 , config1 ) ;
491
500
assertEquals ( 'zh-CN' , container1 . getAttribute ( 'lang' ) ) ;
501
+ assertEquals ( 'zh-CN' , app1 . getAuth ( ) . languageCode ) ;
502
+ assertEquals ( 'zh-CN' , app1 . getExternalAuth ( ) . languageCode ) ;
492
503
app1 . reset ( ) ;
493
504
assertFalse ( container1 . hasAttribute ( 'lang' ) ) ;
505
+ }
494
506
507
+ function testSetLang_codeWithUnderscore ( ) {
495
508
testStubs . replace ( goog , 'LOCALE' , 'zh_CN' ) ;
509
+ // Language code of auth instance is set to goog.LOCALE at initialization.
510
+ // Replace goog.LOCALE and then install instance.
511
+ createAndInstallTestInstances ( ) ;
496
512
app1 . start ( container1 , config1 ) ;
497
513
// The lang should have a dash instead of an underscore.
498
514
assertEquals ( 'zh-CN' , container1 . getAttribute ( 'lang' ) ) ;
515
+ assertEquals ( 'zh-CN' , app1 . getAuth ( ) . languageCode ) ;
516
+ assertEquals ( 'zh-CN' , app1 . getExternalAuth ( ) . languageCode ) ;
499
517
app1 . reset ( ) ;
500
518
assertFalse ( container1 . hasAttribute ( 'lang' ) ) ;
501
519
}
502
520
521
+ function testStart_overrideLanguageCode ( ) {
522
+ // Set the language code of widget to zh-CN.
523
+ testStubs . replace ( goog , 'LOCALE' , 'zh-CN' ) ;
524
+ createAndInstallTestInstances ( ) ;
525
+ testAuth . install ( ) ;
526
+ app = new firebaseui . auth . AuthUI ( testAuth , 'id0' ) ;
527
+ app . getAuth ( ) . assertSetPersistence ( [ 'session' ] , null ) ;
528
+ // Set the language code of auth to de.
529
+ testAuth . languageCode = 'de' ;
530
+ // Override language code of auth to zh-CN.
531
+ app . start ( container1 , config1 ) ;
532
+ assertEquals ( 'zh-CN' , app . getExternalAuth ( ) . languageCode ) ;
533
+ app . reset ( ) ;
534
+ // Confirm language code of auth changed back to de.
535
+ assertEquals ( 'de' , testAuth . languageCode ) ;
536
+ }
537
+
503
538
504
539
function testStart_elementNotFound ( ) {
505
540
// Test widget start method with missing element.
0 commit comments