@@ -479,27 +479,62 @@ function testStart() {
479479
480480
481481function testSetLang ( ) {
482- createAndInstallTestInstances ( ) ;
483482 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 ( ) ;
484486 app1 . start ( container1 , config1 ) ;
485487 assertEquals ( 'de' , container1 . getAttribute ( 'lang' ) ) ;
488+ assertEquals ( 'de' , app1 . getAuth ( ) . languageCode ) ;
489+ assertEquals ( 'de' , app1 . getExternalAuth ( ) . languageCode ) ;
486490 app1 . reset ( ) ;
487491 assertFalse ( container1 . hasAttribute ( 'lang' ) ) ;
492+ }
488493
494+ function testSetLang_codeWithdash ( ) {
489495 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 ( ) ;
490499 app1 . start ( container1 , config1 ) ;
491500 assertEquals ( 'zh-CN' , container1 . getAttribute ( 'lang' ) ) ;
501+ assertEquals ( 'zh-CN' , app1 . getAuth ( ) . languageCode ) ;
502+ assertEquals ( 'zh-CN' , app1 . getExternalAuth ( ) . languageCode ) ;
492503 app1 . reset ( ) ;
493504 assertFalse ( container1 . hasAttribute ( 'lang' ) ) ;
505+ }
494506
507+ function testSetLang_codeWithUnderscore ( ) {
495508 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 ( ) ;
496512 app1 . start ( container1 , config1 ) ;
497513 // The lang should have a dash instead of an underscore.
498514 assertEquals ( 'zh-CN' , container1 . getAttribute ( 'lang' ) ) ;
515+ assertEquals ( 'zh-CN' , app1 . getAuth ( ) . languageCode ) ;
516+ assertEquals ( 'zh-CN' , app1 . getExternalAuth ( ) . languageCode ) ;
499517 app1 . reset ( ) ;
500518 assertFalse ( container1 . hasAttribute ( 'lang' ) ) ;
501519}
502520
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+
503538
504539function testStart_elementNotFound ( ) {
505540 // Test widget start method with missing element.
0 commit comments