Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test CLA webhook #2

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 22 additions & 9 deletions src/components/button/button.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import {
beforeEach,
} from 'angular2/testing';
import {provide, Component} from 'angular2/core';
import {DebugElement} from "angular2/core";
import {DebugElement} from 'angular2/core';
import {By} from 'angular2/platform/browser';

import {MdButton} from './button';
import {AsyncTestFn} from "angular2/testing";
import {AsyncTestFn, FunctionWithParamTokens} from "angular2/testing";


describe('MdButton', () => {
Expand All @@ -23,23 +24,35 @@ describe('MdButton', () => {
beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { builder = tcb; }));

describe('button[md-button]', () => {
it('should handle a click on the button', (done: () => void) => {
//it('should handle a click on the button', (done: () => void) => {
// return builder.createAsync(TestApp).then((fixture) => {
// let testComponent = fixture.debugElement.componentInstance;
// let buttonDebugElement = fixture.debugElement.query(By.css('button'));
//
// buttonDebugElement.nativeElement.click();
// expect(testComponent.clickCount).toBe(1);
// done();
// });
//});

it('should handle a click on the button', testAsync(() => {
return builder.createAsync(TestApp).then((fixture) => {
expect(1).toBe(2);
let testComponent = fixture.debugElement.componentInstance;
let buttonDebugElement = getChildDebugElement(fixture.debugElement, 'button');
let buttonDebugElement = fixture.debugElement.query(By.css('button'));

buttonDebugElement.nativeElement.click();
expect(testComponent.clickCount).toBe(1);
done();
});
});
}));

});
});

/** Gets a child DebugElement by tag name. */
function getChildDebugElement(parent: DebugElement, tagName: string): DebugElement {
return parent.query(debugEl => debugEl.nativeElement.tagName.toLowerCase() == tagName);

/** Shortcut function to use instead of `injectAsync` for less boilerplate on each `it`. */
function testAsync(fn: Function): FunctionWithParamTokens {
return injectAsync([], fn);
}

/** Test component that contains an MdButton. */
Expand Down