Skip to content

Commit 4b5b7d5

Browse files
committed
feat(registries): Add moar tests
1 parent 0f0bd6d commit 4b5b7d5

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ module.exports = {
120120
'<rootDir>/src/app/shared/components/shared-metadata/dialogs/affiliated-institutions-dialog/',
121121
'<rootDir>/src/app/shared/components/shared-metadata/dialogs/contributors-dialog/',
122122
'<rootDir>/src/app/shared/components/shared-metadata/shared-metadata',
123-
'<rootDir>/src/app/shared/components/subjects/',
124123
'<rootDir>/src/app/shared/components/wiki/edit-section/',
125124
'<rootDir>/src/app/shared/components/wiki/wiki-list/',
126125
],

src/app/features/registries/components/metadata/metadata.component.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ describe('MetadataComponent', () => {
9090
expect(tagsSection).toBeDefined();
9191
const titleFieldLabel = titleSection.querySelector('h2');
9292
expect(titleFieldLabel.textContent).toEqual('common.labels.title');
93+
const titleFieldHelpText = titleSection.querySelector('p');
94+
expect(titleFieldHelpText.textContent).toEqual('shared.title.description');
9395
const descriptionFieldLabel = descriptionSection.querySelector('h2');
9496
expect(descriptionFieldLabel.textContent).toEqual('common.labels.description');
97+
const descriptionFieldHelpText = descriptionSection.querySelector('p');
98+
expect(descriptionFieldHelpText.textContent).toEqual('shared.description.descriptionMessage');
9599
});
96100
});

src/app/shared/components/subjects/subjects.component.spec.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
1+
import { Store } from '@ngxs/store';
2+
3+
import { MockProvider } from 'ng-mocks';
4+
15
import { ComponentFixture, TestBed } from '@angular/core/testing';
26

7+
import { MOCK_STORE } from '@osf/shared/mocks';
8+
import { SubjectsSelectors } from '@osf/shared/stores';
9+
310
import { SubjectsComponent } from './subjects.component';
411

12+
import { OSFTestingStoreModule } from '@testing/osf.testing.module';
13+
514
describe('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

Comments
 (0)