mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-11 12:29:53 +00:00
Progress component tests
This commit is contained in:
parent
934c2f9933
commit
6a85c2754e
@ -1,16 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ProgressComponent } from './progress.component';
|
||||
import { MatProgressSpinnerModule } from "@angular/material";
|
||||
import { ProgressService } from "./progress.service";
|
||||
|
||||
describe('ProgressComponent', () => {
|
||||
let component: ProgressComponent;
|
||||
let fixture: ComponentFixture<ProgressComponent>;
|
||||
let progressService: ProgressService;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
MatProgressSpinnerModule,
|
||||
],
|
||||
providers: [ ProgressService ],
|
||||
declarations: [ ProgressComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
progressService = TestBed.get(ProgressService);
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
@ -19,7 +28,21 @@ describe('ProgressComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
it('should create and be invisible', () => {
|
||||
expect(component).toBeTruthy();
|
||||
expect(component.visible).toEqual(false);
|
||||
});
|
||||
|
||||
it( 'should change visibility when activated', () => {
|
||||
progressService.activate();
|
||||
expect(component.visible).toEqual(true);
|
||||
});
|
||||
|
||||
it( 'should change visibility when deactivated', () => {
|
||||
component.visible = true;
|
||||
|
||||
progressService.deactivate();
|
||||
expect(component.visible).toEqual(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -2,6 +2,7 @@ import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { ProgressService } from './progress.service';
|
||||
|
||||
|
||||
describe('ProgressService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ProjectsComponent } from './projects.component';
|
||||
import { MatTooltipModule } from "@angular/material";
|
||||
|
||||
describe('ProjectsComponent', () => {
|
||||
let component: ProjectsComponent;
|
||||
@ -8,6 +9,9 @@ describe('ProjectsComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
MatTooltipModule,
|
||||
],
|
||||
declarations: [ ProjectsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
|
@ -52,16 +52,20 @@ export class ProjectsComponent implements OnInit {
|
||||
})
|
||||
.subscribe((server: Server) => {
|
||||
this.server = server;
|
||||
this.projectService
|
||||
.list(this.server)
|
||||
.subscribe((projects: Project[]) => {
|
||||
this.projectDatabase.addProjects(projects);
|
||||
});
|
||||
this.refresh();
|
||||
});
|
||||
|
||||
this.settings = this.settingsService.getAll();
|
||||
}
|
||||
|
||||
refresh() {
|
||||
this.projectService
|
||||
.list(this.server)
|
||||
.subscribe((projects: Project[]) => {
|
||||
this.projectDatabase.addProjects(projects);
|
||||
});
|
||||
}
|
||||
|
||||
delete(project: Project) {
|
||||
this.projectService.delete(this.server, project.project_id).subscribe(() => {
|
||||
this.projectDatabase.remove(project);
|
||||
@ -72,6 +76,7 @@ export class ProjectsComponent implements OnInit {
|
||||
this.progressService.activate();
|
||||
|
||||
this.projectService.open(this.server, project.project_id).subscribe(() => {
|
||||
this.refresh();
|
||||
}, () => {}, () => {
|
||||
this.progressService.deactivate();
|
||||
});
|
||||
@ -80,7 +85,9 @@ export class ProjectsComponent implements OnInit {
|
||||
close(project: Project) {
|
||||
this.progressService.activate();
|
||||
|
||||
this.projectService.close(this.server, project.project_id).subscribe(() => {}, () => {}, () => {
|
||||
this.projectService.close(this.server, project.project_id).subscribe(() => {
|
||||
this.refresh();
|
||||
}, () => {}, () => {
|
||||
this.progressService.deactivate();
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user