@@ -772,34 +772,48 @@ describe("identity", () => {
772
772
} ) ;
773
773
774
774
describe ( "generateRequestPayload" , ( ) => {
775
- const DISPLAY_NAME_FILED = "displayName" ;
775
+ const DISPLAY_NAME_FIELD = "displayName" ;
776
776
const TEST_RESPONSE = {
777
777
displayName : TEST_NAME ,
778
778
recaptchaPassed : false ,
779
779
} as identity . BeforeCreateResponse ;
780
780
781
781
const EXPECT_PAYLOAD = {
782
- userRecord : { displayName : TEST_NAME , updateMask : DISPLAY_NAME_FILED } ,
782
+ userRecord : { displayName : TEST_NAME , updateMask : DISPLAY_NAME_FIELD } ,
783
783
recaptchaPassed : false ,
784
784
} ;
785
785
786
+ const TEST_RESPONSE_RECAPTCHA_TRUE = {
787
+ recaptchaPassed : true ,
788
+ } as identity . BeforeCreateResponse ;
789
+
790
+ const EXPECT_PAYLOAD_RECAPTCHA_TRUE = {
791
+ recaptchaPassed : true ,
792
+ } ;
793
+
786
794
const TEST_RESPONSE_RECAPTCHA_UNDEFINED = {
787
795
displayName : TEST_NAME ,
788
796
} as identity . BeforeSignInResponse ;
789
797
790
798
const EXPECT_PAYLOAD_UNDEFINED = {
791
- userRecord : { displayName : TEST_NAME , updateMask : DISPLAY_NAME_FILED } ,
799
+ userRecord : { displayName : TEST_NAME , updateMask : DISPLAY_NAME_FIELD } ,
792
800
} ;
793
- it ( "should return empty string on undefined response" , ( ) => {
794
- expect ( identity . generateRequestPayload ( ) ) . to . eq ( "" ) ;
801
+ it ( "should return empty object on undefined response" , ( ) => {
802
+ expect ( identity . generateResponsePayload ( ) ) . to . eql ( { } ) ;
795
803
} ) ;
796
804
797
805
it ( "should exclude recaptchaPass field from updateMask" , ( ) => {
798
- expect ( identity . generateRequestPayload ( TEST_RESPONSE ) ) . to . deep . equal ( EXPECT_PAYLOAD ) ;
806
+ expect ( identity . generateResponsePayload ( TEST_RESPONSE ) ) . to . deep . equal ( EXPECT_PAYLOAD ) ;
807
+ } ) ;
808
+
809
+ it ( "should return recaptchaPass when it is true on response" , ( ) => {
810
+ expect ( identity . generateResponsePayload ( TEST_RESPONSE_RECAPTCHA_TRUE ) ) . to . deep . equal (
811
+ EXPECT_PAYLOAD_RECAPTCHA_TRUE
812
+ ) ;
799
813
} ) ;
800
814
801
815
it ( "should not return recaptchaPass if undefined" , ( ) => {
802
- const payload = identity . generateRequestPayload ( TEST_RESPONSE_RECAPTCHA_UNDEFINED ) ;
816
+ const payload = identity . generateResponsePayload ( TEST_RESPONSE_RECAPTCHA_UNDEFINED ) ;
803
817
expect ( payload . hasOwnProperty ( "recaptchaPassed" ) ) . to . be . false ;
804
818
expect ( payload ) . to . deep . equal ( EXPECT_PAYLOAD_UNDEFINED ) ;
805
819
} ) ;
0 commit comments