This repository has been archived by the owner on May 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(whitespace-issue): add validation to create label field (#2811)
* fix(whitespace-issue): add validation to create label field * fix tslint errors * fix(whitespaceissue): Add test cases * fix(whitespaceissue): fix test cases errors * change indentation in test cases
- Loading branch information
1 parent
91c7476
commit 69c5ce7
Showing
2 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
src/app/components_ngrx/label-selector/label-selector.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,71 @@ | ||
|
||
import { CommonModule } from '@angular/common'; | ||
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; | ||
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing'; | ||
import { HttpModule } from '@angular/http'; | ||
import { Store, StoreModule } from '@ngrx/store'; | ||
import { WidgetsModule } from 'ngx-widgets'; | ||
import { AppState } from './../../../app/states/app.state'; | ||
import { LabelService } from './../../services/label.service'; | ||
import { SelectDropdownModule } from './../../widgets/select-dropdown/select-dropdown.module'; | ||
import { LabelSelectorComponent } from './label-selector.component'; | ||
|
||
import { HttpClientService } from './../../shared/http-module/http.service'; | ||
|
||
let componentInstance: LabelSelectorComponent; | ||
let fixture: ComponentFixture<LabelSelectorComponent>; | ||
let store: Store<AppState>; | ||
|
||
describe('LabelSelectorComponent', () => { | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
WidgetsModule, | ||
CommonModule, | ||
HttpModule, | ||
HttpClientTestingModule, | ||
SelectDropdownModule, | ||
StoreModule.forRoot({}) | ||
], | ||
declarations: [ | ||
LabelSelectorComponent | ||
], | ||
providers: [ LabelService, HttpClientService, Store] | ||
}).compileComponents() | ||
.then(() => { | ||
let store = TestBed.get(Store); | ||
spyOn(store, 'dispatch').and.callThrough(); | ||
fixture = TestBed.createComponent(LabelSelectorComponent); | ||
componentInstance = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
})); | ||
|
||
it(`should create label selector component`, async(() => { | ||
expect(componentInstance).toBeTruthy(); | ||
})); | ||
|
||
it('should recognize a label name field', async(() => { | ||
fixture.detectChanges(); | ||
const labelnameInput = fixture.componentInstance.labelnameInput; | ||
expect(labelnameInput).toBeDefined(); | ||
})); | ||
|
||
it('should remove the white spaces', async(() => { | ||
let labelnameInput = fixture.componentInstance.labelnameInput; | ||
labelnameInput.nativeElement.input = ' '; | ||
fixture.detectChanges(); | ||
expect(labelnameInput.nativeElement.value.length).toBe(0); | ||
})); | ||
|
||
it('should disable the create label button', async(() => { | ||
let labelnameInput = fixture.componentInstance.labelnameInput; | ||
labelnameInput.nativeElement.input = ' '; | ||
fixture.detectChanges(); | ||
// check if button is disabled | ||
expect(fixture.componentInstance['createDisabled']).toBeTruthy(); | ||
expect(labelnameInput.nativeElement.value.length).toBe(0); | ||
})); | ||
|
||
}); |
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