Skip to content

Instantly share code, notes, and snippets.

@JonathanDn
Created December 29, 2016 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonathanDn/9dda7c99a93bcc710d9847b4c54b706c to your computer and use it in GitHub Desktop.
Save JonathanDn/9dda7c99a93bcc710d9847b4c54b706c to your computer and use it in GitHub Desktop.
Angular2 - comp unit testing - my first test
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
// Component Dependencies:
// items:
import {ItemDetailsComponent} from './Item-details.component';
import {ItemOverviewComponent} from './Item-overview/Item-overview.component';
import {ItemFullDataViewComponent} from './Item-full-data-view/Item-full-data-view.component';
// shared
import {SystemIconComponent} from '../../shared/components/system-icon/system-icon.component';
import {SeverityIndicatorComponent} from '../../shared/components/severity-indicator/severity-indicator.component';
import {CategoryComponent} from '../../shared/components/category/category.component';
// pipe dependencies:
import {TranslatePipe} from '../../shared/pipes/translate.pipe';
import {MapToKeyValuePipe} from '../../shared/pipes/maptokeyvalue.pipe';
// services:
import { NgRedux } from 'ng2-redux';
describe("Item details test", () => {
let comp: AlertDetailsComponent;
let fixture: ComponentFixture<AlertDetailsComponent>;
let de: DebugElement;
let el: HTMLElement;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ ItemDetailsComponent,
ItemOverviewComponent,
ItemFullDataViewComponent,
ItemIndicatorComponent,
SystemIconComponent,
CategoryComponent,
TranslatePipe,
MapToKeyValuePipe ],
providers: [NgRedux]
});
fixture = TestBed.createComponent(ItemDetailsComponent);
comp = fixture.componentInstance;
el = fixture.nativeElement;
de = fixture.debugElement;
});
it("should create component:", () => {
expect(comp).toBeDefined();
});
it("Bottom border of header title should be color #4683ff", () => {
expect(comp.bgColor).toBe('#4683ff');
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment