Skip to content

Instantly share code, notes, and snippets.

@psaitu
Last active December 9, 2015 03:16
Show Gist options
  • Select an option

  • Save psaitu/e924e5ac39ddbc69a3af to your computer and use it in GitHub Desktop.

Select an option

Save psaitu/e924e5ac39ddbc69a3af to your computer and use it in GitHub Desktop.
import {Component, View, CORE_DIRECTIVES} from 'angular2/angular2';
import {ROUTER_PROVIDERS, ROUTER_DIRECTIVES, RouterLink} from 'angular2/router';
let templateHTML = require('./SidebarComponent.html');
@Component({
selector: 'SidebarComponent',
inputs: [
'title',
'items'
]
})
@View({
template: templateHTML,
directives: [CORE_DIRECTIVES, ROUTER_DIRECTIVES]
})
export class SidebarComponent {
constructor() {}
}
import {
iit,
it,
ddescribe,
describe,
expect,
inject,
injectAsync,
TestComponentBuilder,
beforeEachProviders
} from 'angular2/testing';
import {Component} from 'angular2/angular2';
import { SidebarComponent } from '../../src/app/components/SidebarComponent/SidebarComponent';
describe('Side Bar Component Component', () => {
var html;
beforeEach(() => {
html = `<SidebarComponent></SidebarComponent>`;
});
it('should have a list of items', injectAsync([TestComponentBuilder], (tcb) => {
return tcb.overrideTemplate(TestComponent, html).createAsync(TestComponent).then((fixture) => {
fixture.detectChanges();
var compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('ul').length).not.toBe(0);
});
}));
it('each item should have multiple links', injectAsync([TestComponentBuilder], (tcb) => {
return tcb.overrideTemplate(TestComponent, html).createAsync(TestComponent).then((fixture) => {
fixture.detectChanges();
var compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelectorAll('ul>li').length).not.toBe(0);
});
}));
});
@Component({selector: 'test-cmp', directives: [SidebarComponent], template: ''})
class TestComponent {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment