-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: switch to karma-coverage (#385)
- Loading branch information
Showing
17 changed files
with
646 additions
and
64 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import {patchConsoleToFailOnError} from './lib/util/patch-console-to-fail-on-error'; | ||
|
||
beforeAll(()=>patchConsoleToFailOnError()); | ||
beforeAll(() => patchConsoleToFailOnError()); |
36 changes: 36 additions & 0 deletions
36
projects/atft/src/lib/actor/data-center/layer/grid-actor.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,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(); | ||
})); | ||
|
||
}); | ||
}); |
66 changes: 66 additions & 0 deletions
66
projects/atft/src/lib/actor/data-center/layout/dagre-composition.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,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(); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |
54 changes: 54 additions & 0 deletions
54
projects/atft/src/lib/actor/data-center/layout/dagre-edge.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,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(); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |
53 changes: 53 additions & 0 deletions
53
projects/atft/src/lib/actor/data-center/layout/dagre-layout.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,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
61
projects/atft/src/lib/actor/data-center/layout/dagre-utils.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,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); | ||
}); | ||
|
||
|
||
}); | ||
}); |
95 changes: 95 additions & 0 deletions
95
projects/atft/src/lib/actor/data-center/layout/dagre-yaml-parser.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,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(); | ||
}); | ||
|
||
}); | ||
|
||
}); |
Oops, something went wrong.