Skip to content

Commit

Permalink
Merge pull request #5 from dataramblers/test
Browse files Browse the repository at this point in the history
Test
  • Loading branch information
sschuepbach authored Mar 4, 2018
2 parents 8373b86 + bbe5faf commit d1d9c88
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 43 deletions.
54 changes: 31 additions & 23 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import {ImageOverviewModule} from './image-overview/image-overview.module';
import {ImageViewerModule} from './image-viewer/image-viewer.module';
import {MaterialModule} from './material.module';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app');
}));
it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
}));
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent,
],
imports: [
ImageOverviewModule,
ImageViewerModule,
MaterialModule
]
}).compileComponents();
}));
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app');
}));
it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
}));
});
43 changes: 27 additions & 16 deletions src/app/image-overview/image-overview.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { ImageOverviewComponent } from './image-overview.component';
import {MaterialModule} from '../material.module';
import {By} from '@angular/platform-browser';

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

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ImageOverviewComponent ]
})
.compileComponents();
}));
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ImageOverviewComponent ],
imports: [MaterialModule]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(ImageOverviewComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
beforeEach(() => {
fixture = TestBed.createComponent(ImageOverviewComponent);
component = fixture.componentInstance;
component.imageNames = Array(10).fill('test');
component.columns = 2;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
it('should create', () => {
expect(component).toBeTruthy();
});

it('should create 10 preview images', () => {
fixture.detectChanges();
expect(fixture.debugElement.queryAll(By.css('mat-grid-tile')).length === 10)
.toBe(true);
});
});
30 changes: 26 additions & 4 deletions src/app/image-viewer/osd-viewport.directive.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
import { OsdViewportDirective } from './osd-viewport.directive';
import {TestBed, ComponentFixture} from '@angular/core/testing';
import {Component, ViewContainerRef} from '@angular/core';

@Component({
template: `<div #osdViewport></div>`
})
class TestOsdComponent {
}


describe('OsdViewportDirective', () => {
it('should create an instance', () => {
const directive = new OsdViewportDirective();
expect(directive).toBeTruthy();
});

let component: TestOsdComponent;
let fixture: ComponentFixture<TestOsdComponent>;
let viewContainerRef: ViewContainerRef;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [TestOsdComponent, OsdViewportDirective]
});
fixture = TestBed.createComponent(TestOsdComponent);
component = fixture.componentInstance;
viewContainerRef = fixture.elementRef.nativeElement.viewContainer;
});

it('should create an instance', () => {
const directive = new OsdViewportDirective(viewContainerRef);
expect(directive).toBeTruthy();
});
});

0 comments on commit d1d9c88

Please sign in to comment.