Skip to content

Commit

Permalink
fix: switch to karma-coverage (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
makimenko committed May 5, 2021
1 parent 42f98d7 commit 89730ac
Show file tree
Hide file tree
Showing 17 changed files with 646 additions and 64 deletions.
2 changes: 1 addition & 1 deletion projects/atft/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {patchConsoleToFailOnError} from './lib/util/patch-console-to-fail-on-error';

beforeAll(()=>patchConsoleToFailOnError());
beforeAll(() => patchConsoleToFailOnError());
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
import {AtftDataCenterActorModule} from '../atft-data-center-actor.module';
import {RendererService} from '../../../renderer';
import {AnimationService} from '../../../animation';
import {StatsService} from '../../../stats';
import {GridActorComponent} from './grid-actor.component';

describe('actor', () => {
describe('GridActorComponent', () => {
let component: GridActorComponent;
let fixture: ComponentFixture<GridActorComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [
AtftDataCenterActorModule
],
providers: [
StatsService,
RendererService,
AnimationService
]
});
fixture = TestBed.createComponent(GridActorComponent);
component = fixture.componentInstance;
return TestBed.compileComponents();
}));


it('init', waitForAsync(() => {
fixture.detectChanges();
expect(component).toBeTruthy();
}));

});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {StatsService} from '../../../stats';
import {RendererService} from '../../../renderer';
import {AnimationService} from '../../../animation';
import {
FontService,
IconService,
ModelService,
ObjLoaderService,
PlaneMeshComponent,
SvgLoaderService,
TextMeshComponent
} from '../../../object';

import {ActorRepositoryService} from '../service';
import {RaycasterService} from '../../../raycaster';
import {EdgeType} from './dagre-edge.component';
import {DagreLayoutComponent} from './dagre-layout.component';
import {DagreCompositionComponent} from './dagre-composition.component';

describe('dagre-layout', () => {

describe('DagreCompositionComponent', () => {
let component: DagreCompositionComponent;
let fixture: ComponentFixture<DagreCompositionComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
DagreCompositionComponent,
PlaneMeshComponent,
TextMeshComponent
],
providers: [
StatsService,
RendererService,
AnimationService,
FontService,
ActorRepositoryService,
ModelService,
DagreLayoutComponent,
RaycasterService,
ObjLoaderService,
SvgLoaderService,
IconService
]
});
fixture = TestBed.createComponent(DagreCompositionComponent);
TestBed.compileComponents();
});

it('init', () => {
component = fixture.componentInstance;
component.height = 10;
fixture.detectChanges();
expect(component).toBeTruthy();

component.ngOnInit();
component.ngOnChanges({});
component.ngOnDestroy();

});

});

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {StatsService} from '../../../stats';
import {RendererService} from '../../../renderer';
import {AnimationService} from '../../../animation';
import {FontService, IconService, ModelService, ObjLoaderService, SvgLoaderService} from '../../../object';

import {ActorRepositoryService} from '../service';
import {RaycasterService} from '../../../raycaster';
import {DagreEdgeComponent, EdgeType} from './dagre-edge.component';
import {DagreLayoutComponent} from './dagre-layout.component';

describe('dagre-layout', () => {

describe('DagreEdgeComponent', () => {
let component: DagreEdgeComponent;
let fixture: ComponentFixture<DagreEdgeComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
DagreEdgeComponent
],
providers: [
StatsService,
RendererService,
AnimationService,
FontService,
ActorRepositoryService,
ModelService,
DagreLayoutComponent,
RaycasterService,
ObjLoaderService,
SvgLoaderService,
IconService
]
});
fixture = TestBed.createComponent(DagreEdgeComponent);
TestBed.compileComponents();
});

it('init', () => {
component = fixture.componentInstance;
component.type = EdgeType.association;
fixture.detectChanges();
expect(component).toBeTruthy();

component.ngOnChanges({});
component.ngOnDestroy();

});

});

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {StatsService} from '../../../stats';
import {RendererService} from '../../../renderer';
import {AnimationService} from '../../../animation';
import {FontService, IconService, ModelService, ObjLoaderService, SvgLoaderService} from '../../../object';

import {ActorRepositoryService} from '../service';
import {DagreLayoutComponent} from './dagre-layout.component';
import {RaycasterService} from '../../../raycaster';

describe('dagre-layout', () => {

describe('DagreLayoutComponent', () => {
let component: DagreLayoutComponent;
let fixture: ComponentFixture<DagreLayoutComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
DagreLayoutComponent
],
providers: [
StatsService,
RendererService,
AnimationService,
FontService,
ActorRepositoryService,
ModelService,
RaycasterService,
DagreLayoutComponent,
ObjLoaderService,
SvgLoaderService,
IconService
]

});
fixture = TestBed.createComponent(DagreLayoutComponent);
TestBed.compileComponents();
});

it('init', () => {
component = fixture.componentInstance;
fixture.detectChanges();
expect(component).toBeTruthy();

component.ngOnChanges({});
component.ngOnDestroy();

});

});

});
61 changes: 61 additions & 0 deletions projects/atft/src/lib/actor/data-center/layout/dagre-utils.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {DagreUtils} from './dagre-utils';
import {GraphModel} from './dagre-model';
import * as dagre from 'dagre';

describe('dagre-layout', () => {
describe('dagre-utils', () => {

it('single node', () => {
const model: GraphModel = {
layout: {
width: 100,
height: 100
},
nodes: [{
name: 'user',
model: 'user',
}]
};
const graph: dagre.graphlib.Graph = DagreUtils.modelToGraph(model);
expect(graph.nodes().length).toBe(1);
expect(graph.nodes()[0]).toBe('user');
});

it('basic graph', () => {
const model: GraphModel = {
layout: {
width: 100,
height: 100
},
nodes: [{
name: 'user',
model: 'user',
}, {
name: 'spa',
type: 'compact',
icon: 'connected_tv'
}, {
name: 'api',
composition: 'backend'
}],
edges: [{
name: 'e1',
from: 'user',
to: 'spa'
}, {
name: 'e2',
from: 'spa',
to: 'api'
}],
compositions: [{
name: 'backend'
}]
};
const graph: dagre.graphlib.Graph = DagreUtils.modelToGraph(model);
expect(graph.nodes().length).toBe(3 /* nodes */ + 1 /* composition */);
expect(graph.edges().length).toBe(2);
});


});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {StatsService} from '../../../stats';
import {RendererService} from '../../../renderer';
import {AnimationService} from '../../../animation';
import {FontService, IconService, ModelService, ObjLoaderService, SvgLoaderService} from '../../../object';
import {DagreYamlParserComponent} from './dagre-yaml-parser.component';
import {ActorRepositoryService} from '../service';
import {DagreLayoutComponent} from './dagre-layout.component';
import {RaycasterService} from '../../../raycaster';

const sampleYaml = `
compositions:
- name: backend
label: Backend
border: frame
- name: data
label: Data Layer
composition: backend
nodes:
- name: user
model: user
- name: spa
type: compact
icon: connected_tv
- name: api
icon: video_settings
composition: backend
- name: db1
label: PostgreSQL
type: barrel
composition: data
- name: db2
label: MongoDB
type: barrel
composition: data
edges:
- from: user
to: spa
- from: spa
to: api
- from: api
to: db1
- from: api
to: db2
`;

describe('dagre-layout', () => {

describe('DagreYamlParserComponent', () => {
let component: DagreYamlParserComponent;
let fixture: ComponentFixture<DagreYamlParserComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
DagreYamlParserComponent,
DagreLayoutComponent
],
providers: [
StatsService,
RendererService,
AnimationService,
FontService,
ActorRepositoryService,
ModelService,
RaycasterService,
DagreLayoutComponent,
ObjLoaderService,
SvgLoaderService,
IconService
]

});
fixture = TestBed.createComponent(DagreYamlParserComponent);
TestBed.compileComponents();
});

it('init', (done) => {
component = fixture.componentInstance;
fixture.detectChanges();

component.yaml = sampleYaml;
component.status.subscribe((status) => {
expect(status).toBeTrue();
done();
});
fixture.detectChanges();
component.parseAndCreate();
});

});

});
Loading

0 comments on commit 89730ac

Please sign in to comment.