@@ -20,6 +20,7 @@ module('Unit | Component | lobbyside-widget', function () {
2020 stages_completed : '0' ,
2121 signed_up_date : '' ,
2222 subscription_type : '' ,
23+ other_emails : '' ,
2324 } ) ;
2425 } ) ;
2526
@@ -57,4 +58,37 @@ module('Unit | Component | lobbyside-widget', function () {
5758
5859 assert . strictEqual ( lobbysideCustomFields ( createUser ( ) ) . subscription_type , 'free' ) ;
5960 } ) ;
61+
62+ test ( 'other_emails joins every non-primary email, comma-separated' , function ( assert ) {
63+ const user = createUser ( {
64+ primaryEmailAddress : 'primary@example.com' ,
65+ emailAddresses : [ { value : 'primary@example.com' } , { value : 'work@example.com' } , { value : 'school@example.com' } ] ,
66+ } as unknown as Partial < UserModel > ) ;
67+
68+ assert . strictEqual ( lobbysideCustomFields ( user ) . other_emails , 'work@example.com, school@example.com' ) ;
69+ } ) ;
70+
71+ test ( 'other_emails excludes the primary email and is empty when it is the only one' , function ( assert ) {
72+ const user = createUser ( {
73+ primaryEmailAddress : 'primary@example.com' ,
74+ emailAddresses : [ { value : 'primary@example.com' } ] ,
75+ } as unknown as Partial < UserModel > ) ;
76+
77+ assert . strictEqual ( lobbysideCustomFields ( user ) . other_emails , '' ) ;
78+ } ) ;
79+
80+ test ( 'other_emails dedupes and drops blank values' , function ( assert ) {
81+ const user = createUser ( {
82+ primaryEmailAddress : 'primary@example.com' ,
83+ emailAddresses : [ { value : 'work@example.com' } , { value : ' work@example.com ' } , { value : '' } , { value : 'alt@example.com' } ] ,
84+ } as unknown as Partial < UserModel > ) ;
85+
86+ assert . strictEqual ( lobbysideCustomFields ( user ) . other_emails , 'work@example.com, alt@example.com' ) ;
87+ } ) ;
88+
89+ test ( 'other_emails is empty when the user has no email addresses' , function ( assert ) {
90+ const user = createUser ( { primaryEmailAddress : 'primary@example.com' , emailAddresses : [ ] } as unknown as Partial < UserModel > ) ;
91+
92+ assert . strictEqual ( lobbysideCustomFields ( user ) . other_emails , '' ) ;
93+ } ) ;
6094} ) ;
0 commit comments