@@ -6,6 +6,7 @@ import { getCurrentDate, parseDate } from "@shared/dateHelpers";
66import { getCurrentBusiness } from "@shared/domain-logic/getCurrentBusiness" ;
77import { modifyCurrentBusiness } from "@shared/domain-logic/modifyCurrentBusiness" ;
88import { createEmptyFormationFormData , emptyAddressData } from "@shared/formationData" ;
9+ import { randomInt } from "@shared/intHelpers" ;
910import { LicenseName } from "@shared/license" ;
1011import {
1112 generateBusiness ,
@@ -593,6 +594,51 @@ describe("userRouter", () => {
593594 } ) ;
594595
595596 describe ( "when businessPersona is 'STARTING'" , ( ) => {
597+ it ( "checks name availability using name from formationFormData" , async ( ) => {
598+ const userData = generateUserDataForBusiness (
599+ generateBusiness ( {
600+ profileData : generateStartingProfileData ( {
601+ businessName : "Business Name in Profile" ,
602+ } ) ,
603+ formationData : generateFormationData ( {
604+ businessNameAvailability : generateBusinessNameAvailability ( {
605+ status : "AVAILABLE" ,
606+ lastUpdatedTimeStamp : sixtyOneMinutesAgo ,
607+ } ) ,
608+ formationFormData : generateFormationFormData ( {
609+ businessName : "Business Name in Formation Form Data" ,
610+ } ) ,
611+ } ) ,
612+ } ) ,
613+ ) ;
614+ stubUnifiedDataClient . get . mockResolvedValue ( userData ) ;
615+
616+ await request ( app ) . get ( `/users/123` ) . set ( "Authorization" , "Bearer user-123-token" ) ;
617+ expect ( stubTimeStampBusinessSearch . search ) . toHaveBeenCalledWith (
618+ "Business Name in Formation Form Data" ,
619+ ) ;
620+ } ) ;
621+
622+ it ( "does not check name availability if formationFormData.businessName is an empty string" , async ( ) => {
623+ const userData = generateUserDataForBusiness (
624+ generateBusiness ( {
625+ formationData : generateFormationData ( {
626+ businessNameAvailability : generateBusinessNameAvailability ( {
627+ status : "AVAILABLE" ,
628+ lastUpdatedTimeStamp : sixtyOneMinutesAgo ,
629+ } ) ,
630+ formationFormData : generateFormationFormData ( {
631+ businessName : "" ,
632+ } ) ,
633+ } ) ,
634+ } ) ,
635+ ) ;
636+ stubUnifiedDataClient . get . mockResolvedValue ( userData ) ;
637+
638+ await request ( app ) . get ( `/users/123` ) . set ( "Authorization" , "Bearer user-123-token" ) ;
639+ expect ( stubTimeStampBusinessSearch . search ) . not . toHaveBeenCalled ( ) ;
640+ } ) ;
641+
596642 it ( "does not update business name search if businessNameAvailability is undefined" , async ( ) => {
597643 const userData = generateUserDataForBusiness (
598644 generateBusiness ( {
@@ -733,13 +779,38 @@ describe("userRouter", () => {
733779
734780 await request ( app ) . get ( `/users/123` ) . set ( "Authorization" , "Bearer user-123-token" ) ;
735781 expect ( stubTimeStampBusinessSearch . search ) . toHaveBeenCalledWith (
736- getCurrentBusiness ( userData ) . profileData . businessName ,
782+ getCurrentBusiness ( userData ) . formationData . formationFormData . businessName ,
737783 ) ;
738784 expect ( stubUpdateOperatingPhase ) . toHaveBeenCalledWith ( userData ) ;
739785 } ) ;
740786 } ) ;
741787
742788 describe ( "when businessPersona is 'FOREIGN' and Foreign type is Nexus" , ( ) => {
789+ it ( "does not seach when nexusDbaName is an empty string" , async ( ) => {
790+ const userData = generateUserDataForBusiness (
791+ generateBusiness ( {
792+ profileData : generateProfileData ( {
793+ businessPersona : "FOREIGN" ,
794+ foreignBusinessTypeIds : [ "employeeOrContractorInNJ" ] ,
795+ } ) ,
796+ formationData : generateFormationData ( {
797+ completedFilingPayment : false ,
798+ businessNameAvailability : generateBusinessNameAvailability ( {
799+ status : "UNAVAILABLE" ,
800+ } ) ,
801+ dbaBusinessNameAvailability : generateBusinessNameAvailability ( {
802+ status : "AVAILABLE" ,
803+ lastUpdatedTimeStamp : sixtyOneMinutesAgo ,
804+ } ) ,
805+ } ) ,
806+ } ) ,
807+ ) ;
808+ stubUnifiedDataClient . get . mockResolvedValue ( userData ) ;
809+
810+ await request ( app ) . get ( `/users/123` ) . set ( "Authorization" , "Bearer user-123-token" ) ;
811+ expect ( stubTimeStampBusinessSearch . search ) . not . toHaveBeenCalled ( ) ;
812+ } ) ;
813+
743814 it ( "does not recheck business name availability if businessNameAvailability and dbaBusinessNameAvailability are undefined" , async ( ) => {
744815 const userData = generateUserDataForBusiness (
745816 generateBusiness ( {
@@ -904,6 +975,7 @@ describe("userRouter", () => {
904975 const userData = generateUserDataForBusiness (
905976 generateBusiness ( {
906977 profileData : generateProfileData ( {
978+ nexusDbaName : `some-dbaName-${ randomInt ( ) } ` ,
907979 businessPersona : "FOREIGN" ,
908980 foreignBusinessTypeIds : [ "employeeOrContractorInNJ" ] ,
909981 } ) ,
0 commit comments