1+ import { Store } from '@ngxs/store' ;
2+
3+ import { MockProvider } from 'ng-mocks' ;
4+
15import { ComponentFixture , TestBed } from '@angular/core/testing' ;
26
7+ import { MOCK_STORE } from '@osf/shared/mocks' ;
8+ import { SubjectsSelectors } from '@osf/shared/stores' ;
9+
310import { SubjectsComponent } from './subjects.component' ;
411
12+ import { OSFTestingStoreModule } from '@testing/osf.testing.module' ;
13+
514describe ( 'SubjectsComponent' , ( ) => {
615 let component : SubjectsComponent ;
716 let fixture : ComponentFixture < SubjectsComponent > ;
817
918 beforeEach ( async ( ) => {
19+ MOCK_STORE . selectSignal . mockImplementation ( ( selector ) => {
20+ switch ( selector ) {
21+ case SubjectsSelectors . getSubjects :
22+ return ( ) => [ ] ;
23+ case SubjectsSelectors . getSubjectsLoading :
24+ return ( ) => false ;
25+ case SubjectsSelectors . getSearchedSubjects :
26+ return ( ) => [ ] ;
27+ case SubjectsSelectors . getSearchedSubjectsLoading :
28+ return ( ) => false ;
29+ }
30+ return null ;
31+ } ) ;
1032 await TestBed . configureTestingModule ( {
11- imports : [ SubjectsComponent ] ,
33+ imports : [ SubjectsComponent , OSFTestingStoreModule ] ,
34+ providers : [ MockProvider ( Store , MOCK_STORE ) ] ,
1235 } ) . compileComponents ( ) ;
1336
1437 fixture = TestBed . createComponent ( SubjectsComponent ) ;
@@ -19,4 +42,11 @@ describe('SubjectsComponent', () => {
1942 it ( 'should create' , ( ) => {
2043 expect ( component ) . toBeTruthy ( ) ;
2144 } ) ;
45+
46+ it ( 'should render with label and description' , ( ) => {
47+ const headerElement = fixture . nativeElement . querySelector ( 'h2' ) ;
48+ expect ( headerElement . textContent ) . toEqual ( 'shared.subjects.title' ) ;
49+ const descriptionElement = fixture . nativeElement . querySelector ( 'p' ) ;
50+ expect ( descriptionElement . textContent ) . toEqual ( 'shared.subjects.description' ) ;
51+ } ) ;
2252} ) ;
0 commit comments