This repository has been archived by the owner on Aug 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/app/components/form-hidden/form-hidden.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { FormInputHiddenComponent } from './form-hidden.component'; | ||
import { ReactiveFormsModule, FormsModule, FormBuilder, FormGroup, FormControl } from '@angular/forms'; | ||
import { APP_BASE_HREF } from '@angular/common'; | ||
import * as _ from 'lodash'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
describe('FormInputHiddenComponent', () => { | ||
let component: FormInputHiddenComponent; | ||
let fixture: ComponentFixture<FormInputHiddenComponent>; | ||
const formBuilder: FormBuilder = new FormBuilder(); | ||
let directiveEl; | ||
let value = "Some Test Value"; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
FormsModule, | ||
ReactiveFormsModule | ||
], | ||
declarations: [FormInputHiddenComponent], | ||
providers: [ | ||
{ provide: APP_BASE_HREF, useValue: '/' } | ||
] | ||
}).compileComponents() | ||
.then(() => { | ||
fixture = TestBed.createComponent(FormInputHiddenComponent); | ||
component = fixture.componentInstance; | ||
|
||
component.field = { type: "hidden", name: "test" }; | ||
component.group = new FormGroup({ | ||
test: new FormControl('') | ||
}); | ||
component.group.patchValue({ | ||
test: value | ||
}); | ||
|
||
|
||
fixture.detectChanges(); | ||
}); | ||
})); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('ensures component is rendered', () => { | ||
directiveEl = fixture.debugElement.query(By.css('input[type=hidden]')); | ||
expect(directiveEl.nativeElement.value).toEqual(value) | ||
}); | ||
|
||
}); |
51 changes: 51 additions & 0 deletions
51
src/app/components/form-label/form-label.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { FormLabelComponent as Type } from './form-label.component'; | ||
import { ReactiveFormsModule, FormsModule, FormBuilder, FormGroup, FormControl } from '@angular/forms'; | ||
import { APP_BASE_HREF } from '@angular/common'; | ||
import * as _ from 'lodash'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
describe('FormInputHiddenComponent', () => { | ||
let component: Type; | ||
let fixture: ComponentFixture<Type>; | ||
const formBuilder: FormBuilder = new FormBuilder(); | ||
let directiveEl; | ||
const value = "Test Value" | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
FormsModule, | ||
ReactiveFormsModule | ||
], | ||
declarations: [Type], | ||
providers: [ | ||
{ provide: APP_BASE_HREF, useValue: '/' } | ||
] | ||
}).compileComponents() | ||
.then(() => { | ||
fixture = TestBed.createComponent(Type); | ||
component = fixture.componentInstance; | ||
|
||
component.field = { type: "label", name: "test" }; | ||
component.group = new FormGroup({ | ||
test: new FormControl('') | ||
}); | ||
component.group.patchValue({ | ||
test: value | ||
}); | ||
|
||
fixture.detectChanges(); | ||
}); | ||
})); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('ensures component is rendered and value is set', () => { | ||
directiveEl = fixture.debugElement.query(By.css('span')); | ||
expect(directiveEl.nativeElement.innerHTML).toEqual(value); | ||
}); | ||
|
||
}); |