Files
angular-docs-cn/modules/@angular/platform-browser/test/browser/title_spec.ts
T

28 lines
940 B
TypeScript
Raw Normal View History

import {ddescribe, describe, it, iit, xit, expect, afterEach} from '@angular/core/testing';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {Title} from '@angular/platform-browser';
2015-03-09 17:39:18 +01:00
export function main() {
describe('title service', () => {
var initialTitle = getDOM().getTitle();
2015-03-09 17:39:18 +01:00
var titleService = new Title();
afterEach(() => { getDOM().setTitle(initialTitle); });
2015-03-09 17:39:18 +01:00
it('should allow reading initial title',
() => { expect(titleService.getTitle()).toEqual(initialTitle); });
2015-03-09 17:39:18 +01:00
it('should set a title on the injected document', () => {
titleService.setTitle('test title');
expect(getDOM().getTitle()).toEqual('test title');
2015-03-09 17:39:18 +01:00
expect(titleService.getTitle()).toEqual('test title');
});
it('should reset title to empty string if title not provided', () => {
titleService.setTitle(null);
expect(getDOM().getTitle()).toEqual('');
2015-03-09 17:39:18 +01:00
});
});
}