mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-17 06:18:09 +00:00
Unit tests added
This commit is contained in:
@ -23,7 +23,7 @@ export class EditStyleActionComponent implements OnInit {
|
||||
|
||||
editStyle() {
|
||||
const dialogRef = this.dialog.open(StyleEditorDialogComponent, {
|
||||
width: '550px',
|
||||
width: '450px',
|
||||
});
|
||||
let instance = dialogRef.componentInstance;
|
||||
instance.server = this.server;
|
||||
|
@ -23,7 +23,7 @@ export class EditTextActionComponent implements OnInit {
|
||||
|
||||
editText() {
|
||||
const dialogRef = this.dialog.open(TextEditorDialogComponent, {
|
||||
width: '550px',
|
||||
width: '450px',
|
||||
});
|
||||
let instance = dialogRef.componentInstance;
|
||||
instance.server = this.server;
|
||||
|
@ -1,14 +1,30 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ContextMenuComponent } from './context-menu.component';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { ChangeDetectorRef, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { ProjectService } from '../../../services/project.service';
|
||||
import { MockedProjectService } from '../../projects/add-blank-project-dialog/add-blank-project-dialog.component.spec';
|
||||
import { MatMenuModule, MatMenuTrigger } from '@angular/material';
|
||||
import { Drawing } from '../../../cartography/models/drawing';
|
||||
import { RectElement } from '../../../cartography/models/drawings/rect-element';
|
||||
import { TextElement } from '../../../cartography/models/drawings/text-element';
|
||||
|
||||
describe('NodeContextMenuComponent', () => {
|
||||
describe('ContextMenuComponent', () => {
|
||||
let component: ContextMenuComponent;
|
||||
let fixture: ComponentFixture<ContextMenuComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ContextMenuComponent ]
|
||||
imports: [
|
||||
MatMenuModule,
|
||||
BrowserModule
|
||||
],
|
||||
providers: [
|
||||
{ provide: ChangeDetectorRef },
|
||||
{ provide: ProjectService, useClass: MockedProjectService }
|
||||
],
|
||||
declarations: [ ContextMenuComponent ],
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
@ -19,7 +35,38 @@ describe('NodeContextMenuComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
// it('should create', () => {
|
||||
// expect(component).toBeTruthy();
|
||||
// });
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should reset capabilities while opening menu for node', () => {
|
||||
component.contextMenu = { openMenu(){} } as MatMenuTrigger;
|
||||
var spy = spyOn<any>(component, "resetCapabilities");
|
||||
|
||||
component.openMenuForNode(null, 0, 0);
|
||||
|
||||
expect(spy.calls.any()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should reset capabilities while opening menu for drawing', () => {
|
||||
component.contextMenu = { openMenu(){} } as MatMenuTrigger;
|
||||
let drawing = {} as Drawing;
|
||||
drawing.element = new RectElement();
|
||||
var spy = spyOn<any>(component, "resetCapabilities");
|
||||
spyOn(component, 'setPosition').and.callFake(() => {});
|
||||
component.openMenuForDrawing(drawing, 0, 0);
|
||||
|
||||
expect(spy.calls.any()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should set correct flag while drawing is text element', () => {
|
||||
component.contextMenu = { openMenu(){} } as MatMenuTrigger;
|
||||
let drawing = {} as Drawing;
|
||||
drawing.element = new TextElement();
|
||||
var spy = spyOn<any>(component, "resetCapabilities");
|
||||
spyOn(component, 'setPosition').and.callFake(() => {});
|
||||
component.openMenuForDrawing(drawing, 0, 0);
|
||||
|
||||
expect(spy.calls.any()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user