1- import { OrganizationRole , OrganizationStatus , PrismaClient } from '@prisma/client' ;
1+ import {
2+ OrganizationRole ,
3+ OrganizationStatus ,
4+ TennesseeRegion ,
5+ OrganizationSize ,
6+ PrismaClient ,
7+ } from '@prisma/client' ;
28import { mockDeep , mockReset } from 'jest-mock-extended' ;
39import admin from 'firebase-admin' ;
410
@@ -18,6 +24,17 @@ jest.mock('@prisma/client', () => ({
1824 PENDING : 'PENDING' ,
1925 SUSPENDED : 'SUSPENDED' ,
2026 } ,
27+ TennesseeRegion : {
28+ EAST : 'EAST' ,
29+ MIDDLE : 'MIDDLE' ,
30+ WEST : 'WEST' ,
31+ } ,
32+ OrganizationSize : {
33+ SMALL : 'SMALL' ,
34+ MEDIUM : 'MEDIUM' ,
35+ LARGE : 'LARGE' ,
36+ EXTRA_LARGE : 'EXTRA_LARGE' ,
37+ } ,
2138} ) ) ;
2239
2340jest . mock ( 'firebase-admin' , ( ) => ( {
@@ -67,12 +84,20 @@ const mockOrganization = {
6784 city : 'Nashville' ,
6885 state : 'TN' ,
6986 zipCode : '37201' ,
70- phoneNumber : '615-555-0123' ,
71- contactPerson : 'Jane Smith' ,
72- contactTitle : 'Executive Director' ,
87+ primaryContactName : 'Jane Smith' ,
88+ primaryContactEmail : 'jane.smith@nonprofitorg.org' ,
89+ primaryContactPhone : '615-555-0123' ,
90+ secondaryContactName : 'John Doe' ,
91+ secondaryContactEmail : 'john.doe@nonprofitorg.org' ,
92+ region : 'MIDDLE' as TennesseeRegion ,
93+ organizationType : 'Senior Services' ,
94+ membershipActive : true ,
95+ membershipDate : new Date ( '2024-01-01' ) ,
96+ membershipRenewalDate : new Date ( '2025-01-01' ) ,
97+ organizationSize : 'MEDIUM' as OrganizationSize ,
7398 role : 'MEMBER' as OrganizationRole ,
7499 status : 'ACTIVE' as OrganizationStatus ,
75- tags : [ 'Nashville' , ' Senior Services', 'Healthcare' ] ,
100+ tags : [ 'Senior Services' , 'Healthcare' , 'Mental Health '] ,
76101} ;
77102
78103const mockAdminOrg = {
@@ -119,11 +144,18 @@ describe('OrganizationController', () => {
119144 email : 'neworg@nonprofit.org' ,
120145 password : 'securePassword123' ,
121146 name : 'New Community Services' ,
122- contactPerson : 'John Smith' ,
123- contactTitle : 'Executive Director' ,
147+ primaryContactName : 'John Smith' ,
148+ primaryContactEmail : 'john@neworg.org' ,
149+ primaryContactPhone : '901-555-0100' ,
150+ secondaryContactName : 'Sarah Johnson' ,
151+ secondaryContactEmail : 'sarah@neworg.org' ,
124152 city : 'Memphis' ,
125153 state : 'TN' ,
126- tags : [ 'Community' , 'Services' ] ,
154+ region : 'WEST' ,
155+ organizationType : 'Community Services' ,
156+ membershipActive : true ,
157+ organizationSize : 'SMALL' ,
158+ tags : [ 'Community Services' , 'Education' ] ,
127159 } ,
128160 } ) ;
129161 const res = createMockResponse ( ) ;
@@ -132,7 +164,7 @@ describe('OrganizationController', () => {
132164 ...mockOrganization ,
133165 email : 'neworg@nonprofit.org' ,
134166 name : 'New Community Services' ,
135- contactPerson : 'John Smith' ,
167+ primaryContactName : 'John Smith' ,
136168 status : 'PENDING' ,
137169 } ) ;
138170 await registerOrganization ( req , res ) ;
@@ -151,16 +183,24 @@ describe('OrganizationController', () => {
151183 data : {
152184 email : 'neworg@nonprofit.org' ,
153185 name : 'New Community Services' ,
154- contactPerson : 'John Smith' ,
155- contactTitle : 'Executive Director' ,
186+ primaryContactName : 'John Smith' ,
187+ primaryContactEmail : 'john@neworg.org' ,
188+ primaryContactPhone : '901-555-0100' ,
189+ secondaryContactName : 'Sarah Johnson' ,
190+ secondaryContactEmail : 'sarah@neworg.org' ,
156191 description : undefined ,
157192 website : undefined ,
158193 address : undefined ,
159194 city : 'Memphis' ,
160195 state : 'TN' ,
161196 zipCode : undefined ,
162- phoneNumber : undefined ,
163- tags : [ 'Community' , 'Services' ] ,
197+ region : 'WEST' ,
198+ organizationType : 'Community Services' ,
199+ membershipActive : true ,
200+ membershipDate : null ,
201+ membershipRenewalDate : null ,
202+ organizationSize : 'SMALL' ,
203+ tags : [ 'Community Services' , 'Education' ] ,
164204 firebaseUid : 'firebase-uid-123' ,
165205 role : 'MEMBER' ,
166206 status : 'PENDING' ,
@@ -185,7 +225,8 @@ describe('OrganizationController', () => {
185225 await registerOrganization ( req , res ) ;
186226 expect ( res . status ) . toHaveBeenCalledWith ( 400 ) ;
187227 expect ( res . json ) . toHaveBeenCalledWith ( {
188- error : 'Email, password, name, and contact person are required' ,
228+ error :
229+ 'Email, password, name, and primary contact information (name, email, phone) are required' ,
189230 } ) ;
190231 } ) ;
191232 it ( 'should prevent duplicate registration - POST /api/organizations/register' , async ( ) => {
@@ -194,7 +235,9 @@ describe('OrganizationController', () => {
194235 email : 'existing@nonprofit.org' ,
195236 password : 'password123' ,
196237 name : 'Existing Organization' ,
197- contactPerson : 'Jane Doe' ,
238+ primaryContactName : 'Jane Doe' ,
239+ primaryContactEmail : 'jane@existing.org' ,
240+ primaryContactPhone : '615-555-9999' ,
198241 } ,
199242 } ) ;
200243 const res = createMockResponse ( ) ;
@@ -285,15 +328,19 @@ describe('OrganizationController', () => {
285328 body : {
286329 name : 'Updated Senior Services' ,
287330 description : 'Updated description' ,
288- contactPerson : 'John Doe' ,
289- contactTitle : 'New Director' ,
331+ primaryContactName : 'John Doe' ,
332+ primaryContactEmail : 'john.doe@updated.org' ,
333+ primaryContactPhone : '615-555-9999' ,
334+ region : 'EAST' ,
335+ organizationType : 'Healthcare' ,
336+ membershipActive : true ,
290337 } ,
291338 } ) ;
292339 const res = createMockResponse ( ) ;
293340 const updatedOrg = {
294341 ...mockOrganization ,
295342 name : 'Updated Senior Services' ,
296- contactPerson : 'John Doe' ,
343+ primaryContactName : 'John Doe' ,
297344 } ;
298345 prismaMock . organization . update . mockResolvedValue ( updatedOrg ) ;
299346 await updateOrganization ( req , res ) ;
@@ -302,8 +349,12 @@ describe('OrganizationController', () => {
302349 data : expect . objectContaining ( {
303350 name : 'Updated Senior Services' ,
304351 description : 'Updated description' ,
305- contactPerson : 'John Doe' ,
306- contactTitle : 'New Director' ,
352+ primaryContactName : 'John Doe' ,
353+ primaryContactEmail : 'john.doe@updated.org' ,
354+ primaryContactPhone : '615-555-9999' ,
355+ region : 'EAST' ,
356+ organizationType : 'Healthcare' ,
357+ membershipActive : true ,
307358 } ) ,
308359 } ) ;
309360 expect ( res . json ) . toHaveBeenCalledWith ( updatedOrg ) ;
0 commit comments