diff --git a/web/src/app/administration/components/access-items-management/access-items-management.component.spec.ts b/web/src/app/administration/components/access-items-management/access-items-management.component.spec.ts index bb17ecaca..bd54eebf3 100644 --- a/web/src/app/administration/components/access-items-management/access-items-management.component.spec.ts +++ b/web/src/app/administration/components/access-items-management/access-items-management.component.spec.ts @@ -186,7 +186,7 @@ describe('AccessItemsManagementComponent', () => { }); })); - it('should display a dialog in when access is revoked', async(() => { + it('should display a dialog when access is revoked', async(() => { app.accessIdSelected = ''; const notificationService = TestBed.inject(NotificationService); const showDialogSpy = jest.spyOn(notificationService, 'showDialog').mockImplementation(); diff --git a/web/src/app/administration/components/classification-types-selector/classification-types-selector.component.html b/web/src/app/administration/components/classification-types-selector/classification-types-selector.component.html index d7a770cd1..f13235b9c 100644 --- a/web/src/app/administration/components/classification-types-selector/classification-types-selector.component.html +++ b/web/src/app/administration/components/classification-types-selector/classification-types-selector.component.html @@ -1,5 +1,5 @@ diff --git a/web/src/app/administration/components/classification-types-selector/classification-types-selector.component.spec.ts b/web/src/app/administration/components/classification-types-selector/classification-types-selector.component.spec.ts new file mode 100644 index 000000000..90ff4de91 --- /dev/null +++ b/web/src/app/administration/components/classification-types-selector/classification-types-selector.component.spec.ts @@ -0,0 +1,67 @@ +import { ClassificationTypesSelectorComponent } from './classification-types-selector.component'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { DebugElement } from '@angular/core'; +import { NgxsModule, Store } from '@ngxs/store'; +import { ClassificationState } from '../../../shared/store/classification-store/classification.state'; +import { MatRadioButton, MatRadioGroup } from '@angular/material/radio'; +import { ClassificationsService } from '../../../shared/services/classifications/classifications.service'; +import { ClassificationCategoriesService } from '../../../shared/services/classification-categories/classification-categories.service'; +import { DomainService } from '../../../shared/services/domain/domain.service'; +import { MatRippleModule } from '@angular/material/core'; + +export const classificationInitState = { + selectedClassificationType: 'Document', + classificationTypes: { + TASK: [], + DOCUMENT: [] + } +}; + +const classificationServiceSpy = jest.fn(); +const classificationCategoriesServiceSpy = jest.fn(); +const domainServiceSpy = jest.fn(); + +describe('ClassificationTypesSelectorComponent', () => { + let fixture: ComponentFixture; + let debugElement: DebugElement; + let app: ClassificationTypesSelectorComponent; + let store: Store; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NgxsModule.forRoot([ClassificationState]), MatRippleModule], + declarations: [ClassificationTypesSelectorComponent, MatRadioButton, MatRadioGroup], + providers: [ + { provide: ClassificationsService, useClass: classificationServiceSpy }, + { provide: ClassificationCategoriesService, useClass: classificationCategoriesServiceSpy }, + { provide: DomainService, useClass: domainServiceSpy } + ] + }).compileComponents(); + + fixture = TestBed.createComponent(ClassificationTypesSelectorComponent); + debugElement = fixture.debugElement; + app = fixture.debugElement.componentInstance; + store = TestBed.inject(Store); + store.reset({ + ...store.snapshot(), + classification: classificationInitState + }); + fixture.detectChanges(); + })); + + it('should create the app', () => { + expect(app).toBeTruthy(); + }); + + it('should display selected classification type', () => { + const button = fixture.debugElement.nativeElement.getElementsByClassName('selected-type'); + expect(button[0].textContent.trim()).toBe('Document'); + }); + + it('should display list of classification types', () => { + const radioButtons = fixture.debugElement.nativeElement.getElementsByClassName('classification-types'); + expect(radioButtons.length).toBe(2); + expect(radioButtons[0].textContent.trim()).toBe('TASK'); + expect(radioButtons[1].textContent.trim()).toBe('DOCUMENT'); + }); +});