|
1 | 1 | 'use strict';
|
| 2 | +import { ComponentFixture, TestBed } from '@angular/core/testing'; |
| 3 | +import { By } from '@angular/platform-browser'; |
| 4 | +import { DebugElement } from '@angular/core'; |
2 | 5 |
|
3 |
| -import {OauthButtonsController} from './index'; |
| 6 | +import { OauthButtonsComponent } from './oauth-buttons.component'; |
4 | 7 |
|
5 |
| -describe('Controller: OauthButtonsController', function() { |
| 8 | +describe('Component: OauthButtonsComponent', () => { |
| 9 | + let comp: OauthButtonsComponent; |
| 10 | + let fixture: ComponentFixture<BannerComponent>; |
| 11 | + let de: DebugElement; |
| 12 | + let el: HTMLElement; |
6 | 13 |
|
7 |
| - var controller, $window; |
| 14 | + beforeEach(() => { |
| 15 | + TestBed.configureTestingModule({ |
| 16 | + declarations: [ OauthButtonsComponent ], // declare the test component |
| 17 | + }); |
8 | 18 |
|
9 |
| - beforeEach(() => { |
10 |
| - angular.module('test', []) |
11 |
| - .controller('OauthButtonsController', OauthButtonsController); |
12 |
| - }); |
13 |
| - // load the controller's module |
14 |
| - beforeEach(angular.mock.module('test')); |
| 19 | + fixture = TestBed.createComponent(OauthButtonsComponent); |
15 | 20 |
|
16 |
| - // Initialize the controller and a mock $window |
17 |
| - beforeEach(inject(function($controller) { |
18 |
| - $window = { |
19 |
| - location: {} |
20 |
| - }; |
| 21 | + comp = fixture.componentInstance; // OauthButtonsComponent test instance |
21 | 22 |
|
22 |
| - controller = $controller('OauthButtonsController', { |
23 |
| - $window: $window |
| 23 | + // query for the title <h1> by CSS element selector |
| 24 | + de = fixture.debugElement.query(By.css('a')); |
| 25 | + el = de.nativeElement; |
24 | 26 | });
|
25 |
| - })); |
26 | 27 |
|
27 |
| - it('should attach loginOauth', function() {<% if (filters.jasmine) { %> |
28 |
| - expect(controller.loginOauth).toEqual(jasmine.any(Function));<% } if (filters.mocha) { %> |
29 |
| - <%= expect() %>controller.loginOauth<%= to() %>.be.a('function');<% } %> |
30 |
| - }); |
| 28 | + it('test', () => { |
| 29 | + console.log(fixture.debugElement.query(By.css('i.fa-google-plus'))); |
| 30 | + fixture.detectChanges(); |
| 31 | + <%_ if (filters.jasmine) { -%> |
| 32 | + expect(el.textContent).toContain('Connect with Google+'); |
| 33 | + <%_ } if (filters.mocha) { -%> |
| 34 | + <%= expect() %>el.textContent<%= to() %>.contain('Connect with Google+'); |
| 35 | + <%_ } -%> |
| 36 | + }); |
31 | 37 | });
|
0 commit comments