fix(platform-browser): provide Title service as part of the module (#11605)

Fixes #11600
This commit is contained in:
Pawel Kozlowski 2016-09-14 22:21:23 +02:00 committed by Alex Eagle
parent 0a2132ef10
commit 85d9db6bc4
2 changed files with 23 additions and 2 deletions

View File

@ -15,6 +15,7 @@ import {WebAnimationsDriver} from '../src/dom/web_animations_driver';
import {BrowserDomAdapter} from './browser/browser_adapter'; import {BrowserDomAdapter} from './browser/browser_adapter';
import {BrowserPlatformLocation} from './browser/location/browser_platform_location'; import {BrowserPlatformLocation} from './browser/location/browser_platform_location';
import {BrowserGetTestability} from './browser/testability'; import {BrowserGetTestability} from './browser/testability';
import {Title} from './browser/title';
import {ELEMENT_PROBE_PROVIDERS} from './dom/debug/ng_probe'; import {ELEMENT_PROBE_PROVIDERS} from './dom/debug/ng_probe';
import {getDOM} from './dom/dom_adapter'; import {getDOM} from './dom/dom_adapter';
import {DomRootRenderer, DomRootRenderer_} from './dom/dom_renderer'; import {DomRootRenderer, DomRootRenderer_} from './dom/dom_renderer';
@ -85,7 +86,7 @@ export function _resolveDefaultAnimationDriver(): AnimationDriver {
{provide: RootRenderer, useExisting: DomRootRenderer}, {provide: RootRenderer, useExisting: DomRootRenderer},
{provide: SharedStylesHost, useExisting: DomSharedStylesHost}, {provide: SharedStylesHost, useExisting: DomSharedStylesHost},
{provide: AnimationDriver, useFactory: _resolveDefaultAnimationDriver}, DomSharedStylesHost, {provide: AnimationDriver, useFactory: _resolveDefaultAnimationDriver}, DomSharedStylesHost,
Testability, EventManager, ELEMENT_PROBE_PROVIDERS Testability, EventManager, ELEMENT_PROBE_PROVIDERS, Title
], ],
exports: [CommonModule, ApplicationModule] exports: [CommonModule, ApplicationModule]
}) })

View File

@ -6,8 +6,11 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Title} from '@angular/platform-browser'; import {Injectable} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import {BrowserModule, Title} from '@angular/platform-browser';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {expect} from '@angular/platform-browser/testing/matchers';
export function main() { export function main() {
describe('title service', () => { describe('title service', () => {
@ -29,6 +32,23 @@ export function main() {
titleService.setTitle(null); titleService.setTitle(null);
expect(getDOM().getTitle()).toEqual(''); expect(getDOM().getTitle()).toEqual('');
}); });
});
describe('integration test', () => {
@Injectable()
class DependsOnTitle {
constructor(public title: Title) {}
}
beforeEach(() => {
TestBed.configureTestingModule({
imports: [BrowserModule],
providers: [DependsOnTitle],
});
});
it('should inject Title service when using BrowserModule',
() => { expect(TestBed.get(DependsOnTitle).title).toBeAnInstanceOf(Title); });
}); });
} }