@@ -15,6 +15,9 @@ import {
1515 waitFor ,
1616} from "../../utils/testUtils" ;
1717import NavBar from "./NavBar" ;
18+ import { mockedOrganisation } from "@/mocks/data/organisation" ;
19+ import { mockedCustodian } from "@/mocks/data/custodian" ;
20+ import { AccountType } from "@/types/accounts" ;
1821
1922jest . mock ( "js-cookie" , ( ) => ( {
2023 get : jest . fn ( ) ,
@@ -118,8 +121,8 @@ describe("NavBar Component", () => {
118121 getUser : ( ) => mockedUser ( ) ,
119122 setUser : jest . fn ( ) ,
120123 config : {
121- organisation : undefined ,
122- custodian : undefined ,
124+ organisation : mockedOrganisation ,
125+ custodian : mockedCustodian ,
123126 } ,
124127 } as unknown as StoreState )
125128 ) ;
@@ -131,6 +134,40 @@ describe("NavBar Component", () => {
131134 expect ( handleLogout ) . toHaveBeenCalled ( ) ;
132135 } ) ;
133136
137+ it ( "displays 'Organisation' chip when the user belongs to an organisation" , ( ) => {
138+ mockUseStore . mockImplementation ( selector =>
139+ selector ( {
140+ getUser : ( ) => mockedUser ( ) ,
141+ setUser : jest . fn ( ) ,
142+ config : {
143+ organisation : mockedOrganisation ,
144+ custodian : undefined ,
145+ } ,
146+ } as unknown as StoreState )
147+ ) ;
148+
149+ render ( < NavBar loggedIn /> ) ;
150+
151+ expect ( screen . getByText ( AccountType . ORGANISATION ) ) . toBeInTheDocument ( ) ;
152+ } ) ;
153+
154+ it ( "displays 'Custodian' chip when the user belongs to an custodian" , ( ) => {
155+ mockUseStore . mockImplementation ( selector =>
156+ selector ( {
157+ getUser : ( ) => mockedUser ( ) ,
158+ setUser : jest . fn ( ) ,
159+ config : {
160+ organisation : undefined ,
161+ custodian : mockedCustodian ,
162+ } ,
163+ } as unknown as StoreState )
164+ ) ;
165+
166+ render ( < NavBar loggedIn /> ) ;
167+
168+ expect ( screen . getByText ( AccountType . CUSTODIAN ) ) . toBeInTheDocument ( ) ;
169+ } ) ;
170+
134171 it ( "displays 'My Account' and 'Sign Out' if the user is authenticated" , ( ) => {
135172 mockGetMe . mockResolvedValueOnce ( {
136173 status : 200 ,
0 commit comments