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