forked from chutney-testing/chutney-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ui): Add some ng test (chutney-testing#76)
- Loading branch information
Showing
12 changed files
with
122 additions
and
69 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
server/conf/ | ||
/backups | ||
.env/ | ||
/ui/coverage | ||
|
||
###################### | ||
# Chutney persistence dir | ||
|
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
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,25 @@ | ||
import { TestBed, async, getTestBed } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { AppComponent } from './app.component'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
|
||
describe('AppComponent', () => { | ||
beforeEach(async(() => { | ||
TestBed.resetTestingModule(); | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
RouterTestingModule, | ||
TranslateModule.forRoot() | ||
], | ||
declarations: [ | ||
AppComponent | ||
], | ||
}).compileComponents(); | ||
})); | ||
it('should create the app', () => { | ||
|
||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.debugElement.componentInstance; | ||
expect(app).toBeTruthy(); | ||
}); | ||
}); |
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,30 @@ | ||
import { BackupsService, BackupDto } from './backups.service'; | ||
import { Backup } from '@core/model/backups.model'; | ||
import { of } from 'rxjs'; | ||
|
||
describe('BackupsService', () => { | ||
|
||
let sut: BackupsService; | ||
let httpClientSpy: { get: jasmine.Spy }; | ||
|
||
beforeEach(() => { | ||
httpClientSpy = jasmine.createSpyObj('HttpClient', ['get']); | ||
sut = new BackupsService(<any> httpClientSpy); | ||
}); | ||
|
||
it('should return expected backups (HttpClient called once)', () => { | ||
const expectedBackups: BackupDto[] = | ||
[new BackupDto(true, true, true, true, true)]; | ||
|
||
httpClientSpy.get.and.returnValue(of(expectedBackups)); | ||
|
||
sut.list().subscribe( | ||
backups => expect(backups).toEqual([new Backup(true, true, true, true, true)], 'expected backups'), | ||
fail | ||
); | ||
expect(httpClientSpy.get.calls.count()).toBe(1, 'one call'); | ||
}); | ||
}); | ||
|
||
|
||
|
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
56 changes: 56 additions & 0 deletions
56
ui/src/app/modules/scenarios/components/scenarii/scenarii.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,56 @@ | ||
import { TestBed, async } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { ScenariiComponent } from './scenarii.component'; | ||
import { SharedModule } from '@shared/shared.module'; | ||
|
||
import { MoleculesModule } from '../../../../molecules/molecules.module'; | ||
|
||
import { MomentModule } from 'angular2-moment'; | ||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; | ||
import { of } from 'rxjs'; | ||
import { ScenarioIndex } from '@core/model'; | ||
import { ScenarioService } from '@core/services'; | ||
|
||
describe('ScenariiComponent', () => { | ||
|
||
beforeEach(async(() => { | ||
TestBed.resetTestingModule(); | ||
const scenarioService = jasmine.createSpyObj('ScenarioService', ['findScenarios']); | ||
const mockScenarioIndex = [new ScenarioIndex('1', 'title1', 'description', 'source', new Date(), [], []), | ||
new ScenarioIndex('2', 'title2', 'description', 'source', new Date(), [], [])]; | ||
scenarioService.findScenarios.and.returnValue(of(mockScenarioIndex)); | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
RouterTestingModule, | ||
TranslateModule.forRoot(), | ||
MoleculesModule, | ||
SharedModule, | ||
MomentModule, | ||
NgbModule | ||
], | ||
declarations: [ | ||
ScenariiComponent | ||
], | ||
providers: [ | ||
{ provide: ScenarioService, useValue: scenarioService } | ||
] | ||
}).compileComponents(); | ||
})); | ||
|
||
it('should create the component ScenariiComponent with two scenarios', () => { | ||
const fixture = TestBed.createComponent(ScenariiComponent); | ||
fixture.detectChanges(); | ||
|
||
const app = fixture.debugElement.componentInstance; | ||
expect(app).toBeTruthy(); | ||
|
||
const html: HTMLElement = fixture.nativeElement; | ||
const cards = html.querySelectorAll('#cards > chutney-scenario-card'); | ||
|
||
expect(cards.length).toBe(2); | ||
expect(cards[0].querySelector('.scenario-title').textContent).toBe('title1'); | ||
expect(cards[1].querySelector('.scenario-title').textContent).toBe('title2'); | ||
expect(fixture.componentInstance.scenarii.length).toBe(2); | ||
}); | ||
}); |
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
ui/src/app/organisms/step/substep/substep.component.spec.ts
This file was deleted.
Oops, something went wrong.
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