fix(platform-browser): provide Title service as part of the module (#11605)
Fixes #11600
This commit is contained in:
parent
0a2132ef10
commit
85d9db6bc4
|
@ -15,6 +15,7 @@ import {WebAnimationsDriver} from '../src/dom/web_animations_driver';
|
|||
import {BrowserDomAdapter} from './browser/browser_adapter';
|
||||
import {BrowserPlatformLocation} from './browser/location/browser_platform_location';
|
||||
import {BrowserGetTestability} from './browser/testability';
|
||||
import {Title} from './browser/title';
|
||||
import {ELEMENT_PROBE_PROVIDERS} from './dom/debug/ng_probe';
|
||||
import {getDOM} from './dom/dom_adapter';
|
||||
import {DomRootRenderer, DomRootRenderer_} from './dom/dom_renderer';
|
||||
|
@ -85,7 +86,7 @@ export function _resolveDefaultAnimationDriver(): AnimationDriver {
|
|||
{provide: RootRenderer, useExisting: DomRootRenderer},
|
||||
{provide: SharedStylesHost, useExisting: DomSharedStylesHost},
|
||||
{provide: AnimationDriver, useFactory: _resolveDefaultAnimationDriver}, DomSharedStylesHost,
|
||||
Testability, EventManager, ELEMENT_PROBE_PROVIDERS
|
||||
Testability, EventManager, ELEMENT_PROBE_PROVIDERS, Title
|
||||
],
|
||||
exports: [CommonModule, ApplicationModule]
|
||||
})
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
* 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 {expect} from '@angular/platform-browser/testing/matchers';
|
||||
|
||||
export function main() {
|
||||
describe('title service', () => {
|
||||
|
@ -29,6 +32,23 @@ export function main() {
|
|||
titleService.setTitle(null);
|
||||
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); });
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue