From b7bb271e9095163b15efa345439e3af61ef93f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Bo=CC=88hm?= Date: Tue, 30 Jan 2018 10:47:08 +0100 Subject: [PATCH] test(book-new): deactivate all tests --- .../book/book-new/book-new.component.spec.ts | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/src/app/book/book-new/book-new.component.spec.ts b/src/app/book/book-new/book-new.component.spec.ts index 42b3f99..ab8cccc 100644 --- a/src/app/book/book-new/book-new.component.spec.ts +++ b/src/app/book/book-new/book-new.component.spec.ts @@ -21,7 +21,7 @@ describe('BookNewComponent', () => { imports: [ FormsModule, ReactiveFormsModule, - RouterTestingModule.withRoutes([]) + RouterTestingModule ], providers: [{ provide: BookDataService, useClass: BookStaticAsyncDataService }] }) @@ -31,38 +31,28 @@ describe('BookNewComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(BookNewComponent); component = fixture.componentInstance; - component.ngOnInit(); fixture.detectChanges(); compiled = fixture.debugElement.nativeElement; })); + // Tip: This tests based on reactive-forms, take a look at the BookNew Class (form attribute) it('should be created', () => { expect(component).toBeTruthy(); }); it('should be invalid when initialized', () => { - expect(component.form.valid).toBeFalsy() + expect(true).toBeFalsy(); }); - it('should require title', () => { - let errors = {}; - let title = component.form.controls['title']; - errors = title.errors || {}; - expect(errors['required']).toBeTruthy(); + it('should require title otherwise mark form as invalid', () => { + expect(true).toBeFalsy(); }); - it('should call createBook on submit', inject([BookDataService], (service: BookDataService) => { - const serviceSpy = spyOn(service, 'createBook').and.callThrough(); - - component.form.controls['isbn'].setValue("1234567890123"); - component.form.controls['title'].setValue("Test Book"); - component.form.controls['author'].setValue("A author"); - - expect(component.form.valid).toBeTruthy(); - - component.onSubmit() - - expect(serviceSpy.calls.any()).toBeTruthy(); + it('should be valid if all values are valid', () => { + expect(true).toBeFalsy(); + }); + it('should call BookData.createBook on submit', inject([BookDataService], (service: BookDataService) => { + expect(true).toBeFalsy(); })); });