@@ -156,4 +156,74 @@ describe('<CoursesTab />', () => {
156156 const state = store . getState ( ) ;
157157 expect ( state . studioHome . studioHomeCoursesRequestParams ) . toStrictEqual ( studioHomeCoursesRequestParamsDefault ) ;
158158 } ) ;
159+
160+ it ( 'should render displayNumber in the card subtitle when it is provided' , ( ) => {
161+ const courseWithDisplayNumber = {
162+ ...studioHomeMock . courses [ 0 ] ,
163+ number : '123' ,
164+ displayNumber : 'DISP-999' ,
165+ } ;
166+ const customStoreData = {
167+ studioHomeData : {
168+ courses : [ courseWithDisplayNumber ] ,
169+ numPages : 1 ,
170+ coursesCount : 1 ,
171+ } ,
172+ } ;
173+ renderComponent ( { } , customStoreData ) ;
174+ expect ( screen . getByText ( / D I S P - 9 9 9 / ) ) . toBeInTheDocument ( ) ;
175+ expect ( screen . queryByText ( / \/ 1 2 3 \/ / ) ) . not . toBeInTheDocument ( ) ;
176+ } ) ;
177+
178+ it ( 'should fall back to number in the card subtitle when displayNumber is empty' , ( ) => {
179+ const courseWithEmptyDisplayNumber = {
180+ ...studioHomeMock . courses [ 0 ] ,
181+ number : '123' ,
182+ displayNumber : '' ,
183+ } ;
184+ const customStoreData = {
185+ studioHomeData : {
186+ courses : [ courseWithEmptyDisplayNumber ] ,
187+ numPages : 1 ,
188+ coursesCount : 1 ,
189+ } ,
190+ } ;
191+ renderComponent ( { } , customStoreData ) ;
192+ expect ( screen . getByText ( / \/ 1 2 3 \/ / ) ) . toBeInTheDocument ( ) ;
193+ } ) ;
194+
195+ it ( 'should render displayOrg in the card subtitle when it is provided' , ( ) => {
196+ const courseWithDisplayOrg = {
197+ ...studioHomeMock . courses [ 0 ] ,
198+ org : 'HarvardX' ,
199+ displayOrg : 'Harvard University' ,
200+ } ;
201+ const customStoreData = {
202+ studioHomeData : {
203+ courses : [ courseWithDisplayOrg ] ,
204+ numPages : 1 ,
205+ coursesCount : 1 ,
206+ } ,
207+ } ;
208+ renderComponent ( { } , customStoreData ) ;
209+ expect ( screen . getByText ( / H a r v a r d U n i v e r s i t y \/ / ) ) . toBeInTheDocument ( ) ;
210+ expect ( screen . queryByText ( / H a r v a r d X \/ / ) ) . not . toBeInTheDocument ( ) ;
211+ } ) ;
212+
213+ it ( 'should fall back to org in the card subtitle when displayOrg is empty' , ( ) => {
214+ const courseWithEmptyDisplayOrg = {
215+ ...studioHomeMock . courses [ 0 ] ,
216+ org : 'HarvardX' ,
217+ displayOrg : '' ,
218+ } ;
219+ const customStoreData = {
220+ studioHomeData : {
221+ courses : [ courseWithEmptyDisplayOrg ] ,
222+ numPages : 1 ,
223+ coursesCount : 1 ,
224+ } ,
225+ } ;
226+ renderComponent ( { } , customStoreData ) ;
227+ expect ( screen . getByText ( / H a r v a r d X \/ / ) ) . toBeInTheDocument ( ) ;
228+ } ) ;
159229} ) ;
0 commit comments