@@ -41,6 +41,38 @@ describe('Integration Model', function () {
4141 } ) ;
4242 } ) ;
4343
44+ describe ( 'requiresPasswordForLogin' , function ( ) {
45+ it ( 'is true when keys are required (Sync), regardless of keys-optional support' , ( ) => {
46+ jest . spyOn ( model , 'requiresKeys' ) . mockReturnValue ( true ) ;
47+ jest . spyOn ( model , 'wantsKeysIfPasswordEntered' ) . mockReturnValue ( false ) ;
48+ expect ( model . requiresPasswordForLogin ( true ) ) . toBe ( true ) ;
49+ } ) ;
50+
51+ it ( 'is true for a non-Sync client that wants keys when keys are not optional' , ( ) => {
52+ jest . spyOn ( model , 'requiresKeys' ) . mockReturnValue ( false ) ;
53+ jest . spyOn ( model , 'wantsKeysIfPasswordEntered' ) . mockReturnValue ( true ) ;
54+ expect ( model . requiresPasswordForLogin ( false ) ) . toBe ( true ) ;
55+ } ) ;
56+
57+ it ( 'is false for a non-Sync client that wants keys when the browser supports keys-optional login' , ( ) => {
58+ jest . spyOn ( model , 'requiresKeys' ) . mockReturnValue ( false ) ;
59+ jest . spyOn ( model , 'wantsKeysIfPasswordEntered' ) . mockReturnValue ( true ) ;
60+ expect ( model . requiresPasswordForLogin ( true ) ) . toBe ( false ) ;
61+ } ) ;
62+
63+ it ( 'is false when the client does not want keys' , ( ) => {
64+ jest . spyOn ( model , 'requiresKeys' ) . mockReturnValue ( false ) ;
65+ jest . spyOn ( model , 'wantsKeysIfPasswordEntered' ) . mockReturnValue ( false ) ;
66+ expect ( model . requiresPasswordForLogin ( false ) ) . toBe ( false ) ;
67+ } ) ;
68+
69+ it ( 'treats an omitted keys-optional flag as "not supported"' , ( ) => {
70+ jest . spyOn ( model , 'requiresKeys' ) . mockReturnValue ( false ) ;
71+ jest . spyOn ( model , 'wantsKeysIfPasswordEntered' ) . mockReturnValue ( true ) ;
72+ expect ( model . requiresPasswordForLogin ( ) ) . toBe ( true ) ;
73+ } ) ;
74+ } ) ;
75+
4476 describe ( 'isTrusted' , function ( ) {
4577 it ( 'returns `true`' , ( ) => {
4678 expect ( model . isTrusted ( ) ) . toBeTruthy ( ) ;
0 commit comments