Skip to content

Commit

Permalink
fix: typed forms
Browse files Browse the repository at this point in the history
  • Loading branch information
ronnymikalsen committed Oct 25, 2022
1 parent c3d9fca commit 84294bd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,29 @@ describe('CanvasGroupDialogComponent', () => {
let intl: MimeViewerIntl;
let canvasService: CanvasServiceStub;

beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [NoopAnimationsModule, HttpClientTestingModule, SharedModule],
declarations: [CanvasGroupDialogComponent],
providers: [
ViewerService,
ClickService,
ModeService,
ViewerLayoutService,
MimeViewerIntl,
StyleService,
HighlightService,
{
provide: IiifContentSearchService,
useClass: IiifContentSearchServiceStub,
},
{ provide: MatDialogRef, useClass: MatDialogRefStub },
{ provide: CanvasService, useClass: CanvasServiceStub },
{ provide: AltoService, useClass: AltoServiceStub },
{ provide: IiifManifestService, useClass: IiifManifestServiceStub },
],
}).compileComponents();
})
);
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [NoopAnimationsModule, HttpClientTestingModule, SharedModule],
declarations: [CanvasGroupDialogComponent],
providers: [
ViewerService,
ClickService,
ModeService,
ViewerLayoutService,
MimeViewerIntl,
StyleService,
HighlightService,
{
provide: IiifContentSearchService,
useClass: IiifContentSearchServiceStub,
},
{ provide: MatDialogRef, useClass: MatDialogRefStub },
{ provide: CanvasService, useClass: CanvasServiceStub },
{ provide: AltoService, useClass: AltoServiceStub },
{ provide: IiifManifestService, useClass: IiifManifestServiceStub },
],
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(CanvasGroupDialogComponent);
Expand Down Expand Up @@ -96,9 +94,9 @@ describe('CanvasGroupDialogComponent', () => {
it('should show a error message if user enters a canvas group number index that does not exists', fakeAsync(async () => {
canvasService._currentNumberOfCanvasGroups.next(10);

component.canvasGroupControl.setValue(11);
component.canvasGroupControl?.setValue(11);

component.canvasGroupControl.markAsTouched();
component.canvasGroupControl?.markAsTouched();
fixture.detectChanges();
flush();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {
OnInit,
} from '@angular/core';
import {
FormBuilder,
FormControl,
FormGroup,
UntypedFormBuilder,
Validators,
} from '@angular/forms';
import { MatDialogRef } from '@angular/material/dialog';
Expand All @@ -31,15 +31,15 @@ export class CanvasGroupDialogComponent implements OnInit, OnDestroy {

constructor(
private dialogRef: MatDialogRef<CanvasGroupDialogComponent>,
private fb: UntypedFormBuilder,
private fb: FormBuilder,
private viewerService: ViewerService,
private canvasService: CanvasService,
public intl: MimeViewerIntl,
private changeDetectorRef: ChangeDetectorRef
) {
this.numberOfCanvases = this.canvasService.numberOfCanvases;
this.canvasGroupForm = this.fb.group({
canvasGroupControl: new FormControl(null, [
canvasGroupControl: new FormControl<number | null>(null, [
Validators.required,
Validators.min(1),
Validators.max(this.numberOfCanvases),
Expand Down

0 comments on commit 84294bd

Please sign in to comment.