test: fix existing tests by removing usage of obsolete stuff like component level directives, AsyncCompleter and TestComponentBuilder
This commit is contained in:
@ -8,8 +8,7 @@
|
||||
|
||||
import {ResourceLoader, UrlResolver} from '@angular/compiler';
|
||||
import {BaseException, Component} from '@angular/core';
|
||||
import {TestBed, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
import {TestBed, async, fakeAsync, tick} from '@angular/core/testing';
|
||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
|
||||
import {CachedResourceLoader} from '../../src/resource_loader/resource_loader_cache';
|
||||
@ -43,28 +42,30 @@ export function main() {
|
||||
}).toThrowError('CachedResourceLoader: Template cache was not found in $templateCache.');
|
||||
});
|
||||
|
||||
it('should resolve the Promise with the cached file content on success',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
it('should resolve the Promise with the cached file content on success', async(() => {
|
||||
setTemplateCache({'test.html': '<div>Hello</div>'});
|
||||
resourceLoader = new CachedResourceLoader();
|
||||
resourceLoader.get('test.html').then((text) => {
|
||||
expect(text).toEqual('<div>Hello</div>');
|
||||
async.done();
|
||||
});
|
||||
resourceLoader.get('test.html').then((text) => { expect(text).toBe('<div>Hello</div>'); });
|
||||
}));
|
||||
|
||||
it('should reject the Promise on failure',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
it('should reject the Promise on failure', async(() => {
|
||||
resourceLoader = new CachedResourceLoader();
|
||||
resourceLoader.get('unknown.html')
|
||||
.then((text) => { throw new BaseException('Not expected to succeed.'); })
|
||||
.catch((error) => { async.done(); });
|
||||
.catch((error) => {/** success */});
|
||||
}));
|
||||
|
||||
it('should allow fakeAsync Tests to load components with templateUrl synchronously',
|
||||
fakeAsync(() => {
|
||||
TestBed.configureTestingModule({declarations: [TestComponent]});
|
||||
TestBed.compileComponents();
|
||||
tick();
|
||||
|
||||
let fixture = TestBed.createComponent(TestComponent);
|
||||
fixture.detectChanges();
|
||||
|
||||
// This should initialize the fixture.
|
||||
tick();
|
||||
|
||||
expect(fixture.debugElement.children[0].nativeElement).toHaveText('Hello');
|
||||
}));
|
||||
});
|
||||
|
Reference in New Issue
Block a user