test(ivy): enable ivy tests for platform-browser (#27460)
PR Close #27460
This commit is contained in:
parent
b25f06ee7c
commit
c07afd9db1
@ -22,6 +22,7 @@ ts_library(
|
|||||||
"//packages/platform-browser-dynamic",
|
"//packages/platform-browser-dynamic",
|
||||||
"//packages/platform-browser/animations",
|
"//packages/platform-browser/animations",
|
||||||
"//packages/platform-browser/testing",
|
"//packages/platform-browser/testing",
|
||||||
|
"//packages/private/testing",
|
||||||
"@rxjs",
|
"@rxjs",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -29,9 +30,6 @@ ts_library(
|
|||||||
jasmine_node_test(
|
jasmine_node_test(
|
||||||
name = "test",
|
name = "test",
|
||||||
bootstrap = ["angular/tools/testing/init_node_spec.js"],
|
bootstrap = ["angular/tools/testing/init_node_spec.js"],
|
||||||
tags = [
|
|
||||||
"fixme-ivy-aot",
|
|
||||||
],
|
|
||||||
deps = [
|
deps = [
|
||||||
":test_lib",
|
":test_lib",
|
||||||
"//tools/testing:node",
|
"//tools/testing:node",
|
||||||
@ -43,9 +41,6 @@ ts_web_test_suite(
|
|||||||
static_files = [
|
static_files = [
|
||||||
":static_assets/test.html",
|
":static_assets/test.html",
|
||||||
],
|
],
|
||||||
tags = [
|
|
||||||
"fixme-ivy-aot",
|
|
||||||
],
|
|
||||||
deps = [
|
deps = [
|
||||||
":test_lib",
|
":test_lib",
|
||||||
],
|
],
|
||||||
|
@ -18,6 +18,7 @@ import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
|||||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||||
import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
|
import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
|
||||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||||
|
import {fixmeIvy} from '@angular/private/testing';
|
||||||
|
|
||||||
@Component({selector: 'non-existent', template: ''})
|
@Component({selector: 'non-existent', template: ''})
|
||||||
class NonExistentComp {
|
class NonExistentComp {
|
||||||
@ -159,6 +160,7 @@ function bootstrap(
|
|||||||
|
|
||||||
afterEach(destroyPlatform);
|
afterEach(destroyPlatform);
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should throw if bootstrapped Directive is not a Component',
|
it('should throw if bootstrapped Directive is not a Component',
|
||||||
inject([AsyncTestCompleter], (done: AsyncTestCompleter) => {
|
inject([AsyncTestCompleter], (done: AsyncTestCompleter) => {
|
||||||
const logger = new MockConsole();
|
const logger = new MockConsole();
|
||||||
@ -186,7 +188,9 @@ function bootstrap(
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should throw if no provider', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
fixmeIvy('unknown') &&
|
||||||
|
it('should throw if no provider',
|
||||||
|
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||||
const logger = new MockConsole();
|
const logger = new MockConsole();
|
||||||
const errorHandler = new ErrorHandler();
|
const errorHandler = new ErrorHandler();
|
||||||
(errorHandler as any)._console = logger as any;
|
(errorHandler as any)._console = logger as any;
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
import {Component, Renderer2, ViewEncapsulation} from '@angular/core';
|
import {Component, Renderer2, ViewEncapsulation} from '@angular/core';
|
||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||||
|
import {NAMESPACE_URIS} from '@angular/platform-browser/src/dom/dom_renderer';
|
||||||
import {browserDetection} from '@angular/platform-browser/testing/src/browser_util';
|
import {browserDetection} from '@angular/platform-browser/testing/src/browser_util';
|
||||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||||
import {NAMESPACE_URIS} from '../../src/dom/dom_renderer';
|
|
||||||
|
|
||||||
{
|
{
|
||||||
describe('DefaultDomRendererV2', () => {
|
describe('DefaultDomRendererV2', () => {
|
||||||
|
@ -8,8 +8,7 @@
|
|||||||
|
|
||||||
import {SecurityContext} from '@angular/core';
|
import {SecurityContext} from '@angular/core';
|
||||||
import * as t from '@angular/core/testing/src/testing_internal';
|
import * as t from '@angular/core/testing/src/testing_internal';
|
||||||
|
import {DomSanitizerImpl} from '@angular/platform-browser/src/security/dom_sanitization_service';
|
||||||
import {DomSanitizerImpl} from '../../src/security/dom_sanitization_service';
|
|
||||||
|
|
||||||
{
|
{
|
||||||
t.describe('DOM Sanitization Service', () => {
|
t.describe('DOM Sanitization Service', () => {
|
||||||
|
@ -10,6 +10,7 @@ import {CompilerConfig, ResourceLoader} from '@angular/compiler';
|
|||||||
import {CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, Directive, Inject, Injectable, Injector, Input, NgModule, Optional, Pipe, SkipSelf, ɵstringify as stringify} from '@angular/core';
|
import {CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, Directive, Inject, Injectable, Injector, Input, NgModule, Optional, Pipe, SkipSelf, ɵstringify as stringify} from '@angular/core';
|
||||||
import {TestBed, async, fakeAsync, getTestBed, inject, tick, withModule} from '@angular/core/testing';
|
import {TestBed, async, fakeAsync, getTestBed, inject, tick, withModule} from '@angular/core/testing';
|
||||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||||
|
import {fixmeIvy} from '@angular/private/testing';
|
||||||
|
|
||||||
// Services, and components for the tests.
|
// Services, and components for the tests.
|
||||||
|
|
||||||
@ -250,7 +251,7 @@ class CompWithUrlTemplate {
|
|||||||
expect(compFixture.componentInstance).toBeAnInstanceOf(CompUsingModuleDirectiveAndPipe);
|
expect(compFixture.componentInstance).toBeAnInstanceOf(CompUsingModuleDirectiveAndPipe);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use set up directives and pipes', () => {
|
fixmeIvy('unknown') && it('should use set up directives and pipes', () => {
|
||||||
const compFixture = TestBed.createComponent(CompUsingModuleDirectiveAndPipe);
|
const compFixture = TestBed.createComponent(CompUsingModuleDirectiveAndPipe);
|
||||||
const el = compFixture.debugElement;
|
const el = compFixture.debugElement;
|
||||||
|
|
||||||
@ -287,6 +288,7 @@ class CompWithUrlTemplate {
|
|||||||
expect(service.value).toEqual('real value');
|
expect(service.value).toEqual('real value');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should use set up directives and pipes', withModule(moduleConfig, () => {
|
it('should use set up directives and pipes', withModule(moduleConfig, () => {
|
||||||
const compFixture = TestBed.createComponent(CompUsingModuleDirectiveAndPipe);
|
const compFixture = TestBed.createComponent(CompUsingModuleDirectiveAndPipe);
|
||||||
const el = compFixture.debugElement;
|
const el = compFixture.debugElement;
|
||||||
@ -307,7 +309,7 @@ class CompWithUrlTemplate {
|
|||||||
TestBed.compileComponents();
|
TestBed.compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
isBrowser &&
|
fixmeIvy('unknown') && isBrowser &&
|
||||||
it('should allow to createSync components with templateUrl after explicit async compilation',
|
it('should allow to createSync components with templateUrl after explicit async compilation',
|
||||||
() => {
|
() => {
|
||||||
const fixture = TestBed.createComponent(CompWithUrlTemplate);
|
const fixture = TestBed.createComponent(CompWithUrlTemplate);
|
||||||
@ -368,7 +370,7 @@ class CompWithUrlTemplate {
|
|||||||
.overrideDirective(
|
.overrideDirective(
|
||||||
SomeDirective, {set: {selector: '[someDir]', host: {'[title]': 'someProp'}}});
|
SomeDirective, {set: {selector: '[someDir]', host: {'[title]': 'someProp'}}});
|
||||||
});
|
});
|
||||||
it('should work', () => {
|
fixmeIvy('unknown') && it('should work', () => {
|
||||||
const compFixture = TestBed.createComponent(SomeComponent);
|
const compFixture = TestBed.createComponent(SomeComponent);
|
||||||
compFixture.detectChanges();
|
compFixture.detectChanges();
|
||||||
expect(compFixture.debugElement.children[0].properties['title']).toEqual('hello');
|
expect(compFixture.debugElement.children[0].properties['title']).toEqual('hello');
|
||||||
@ -383,7 +385,7 @@ class CompWithUrlTemplate {
|
|||||||
.overridePipe(SomePipe, {set: {name: 'somePipe'}})
|
.overridePipe(SomePipe, {set: {name: 'somePipe'}})
|
||||||
.overridePipe(SomePipe, {add: {pure: false}});
|
.overridePipe(SomePipe, {add: {pure: false}});
|
||||||
});
|
});
|
||||||
it('should work', () => {
|
fixmeIvy('unknown') && it('should work', () => {
|
||||||
const compFixture = TestBed.createComponent(SomeComponent);
|
const compFixture = TestBed.createComponent(SomeComponent);
|
||||||
compFixture.detectChanges();
|
compFixture.detectChanges();
|
||||||
expect(compFixture.nativeElement).toHaveText('transformed hello');
|
expect(compFixture.nativeElement).toHaveText('transformed hello');
|
||||||
@ -453,7 +455,7 @@ class CompWithUrlTemplate {
|
|||||||
expect(TestBed.get('a')).toBe('mockA: depValue');
|
expect(TestBed.get('a')).toBe('mockA: depValue');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support SkipSelf', () => {
|
fixmeIvy('unknown') && it('should support SkipSelf', () => {
|
||||||
@NgModule({
|
@NgModule({
|
||||||
providers: [
|
providers: [
|
||||||
{provide: 'a', useValue: 'aValue'},
|
{provide: 'a', useValue: 'aValue'},
|
||||||
@ -493,6 +495,7 @@ class CompWithUrlTemplate {
|
|||||||
expect(someModule).toBeAnInstanceOf(SomeModule);
|
expect(someModule).toBeAnInstanceOf(SomeModule);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should keep imported NgModules lazy with deprecatedOverrideProvider', () => {
|
it('should keep imported NgModules lazy with deprecatedOverrideProvider', () => {
|
||||||
let someModule: SomeModule|undefined;
|
let someModule: SomeModule|undefined;
|
||||||
|
|
||||||
@ -544,7 +547,7 @@ class CompWithUrlTemplate {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('in Components', () => {
|
describe('in Components', () => {
|
||||||
it('should support useValue', () => {
|
fixmeIvy('unknown') && it('should support useValue', () => {
|
||||||
@Component({
|
@Component({
|
||||||
template: '',
|
template: '',
|
||||||
providers: [
|
providers: [
|
||||||
@ -561,7 +564,7 @@ class CompWithUrlTemplate {
|
|||||||
expect(ctx.debugElement.injector.get('a')).toBe('mockValue');
|
expect(ctx.debugElement.injector.get('a')).toBe('mockValue');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support useFactory', () => {
|
fixmeIvy('unknown') && it('should support useFactory', () => {
|
||||||
@Component({
|
@Component({
|
||||||
template: '',
|
template: '',
|
||||||
providers: [
|
providers: [
|
||||||
@ -580,7 +583,7 @@ class CompWithUrlTemplate {
|
|||||||
expect(ctx.debugElement.injector.get('a')).toBe('mockA: depValue');
|
expect(ctx.debugElement.injector.get('a')).toBe('mockA: depValue');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support @Optional without matches', () => {
|
fixmeIvy('unknown') && it('should support @Optional without matches', () => {
|
||||||
@Component({
|
@Component({
|
||||||
template: '',
|
template: '',
|
||||||
providers: [
|
providers: [
|
||||||
@ -598,7 +601,7 @@ class CompWithUrlTemplate {
|
|||||||
expect(ctx.debugElement.injector.get('a')).toBe('mockA: null');
|
expect(ctx.debugElement.injector.get('a')).toBe('mockA: null');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support Optional with matches', () => {
|
fixmeIvy('unknown') && it('should support Optional with matches', () => {
|
||||||
@Component({
|
@Component({
|
||||||
template: '',
|
template: '',
|
||||||
providers: [
|
providers: [
|
||||||
@ -617,7 +620,7 @@ class CompWithUrlTemplate {
|
|||||||
expect(ctx.debugElement.injector.get('a')).toBe('mockA: depValue');
|
expect(ctx.debugElement.injector.get('a')).toBe('mockA: depValue');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support SkipSelf', () => {
|
fixmeIvy('unknown') && it('should support SkipSelf', () => {
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[myDir]',
|
selector: '[myDir]',
|
||||||
providers: [
|
providers: [
|
||||||
@ -644,7 +647,7 @@ class CompWithUrlTemplate {
|
|||||||
expect(ctx.debugElement.children[0].injector.get('a')).toBe('mockA: parentDepValue');
|
expect(ctx.debugElement.children[0].injector.get('a')).toBe('mockA: parentDepValue');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support multiple providers in a template', () => {
|
fixmeIvy('unknown') && it('should support multiple providers in a template', () => {
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[myDir1]',
|
selector: '[myDir1]',
|
||||||
providers: [
|
providers: [
|
||||||
@ -689,20 +692,22 @@ class CompWithUrlTemplate {
|
|||||||
constructor(@Inject('a') a: any, @Inject('b') b: any) {}
|
constructor(@Inject('a') a: any, @Inject('b') b: any) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should inject providers that were declared before it', () => {
|
it('should inject providers that were declared before it', () => {
|
||||||
TestBed.overrideProvider(
|
TestBed.overrideProvider(
|
||||||
'b', {useFactory: (a: string) => `mockB: ${a}`, deps: ['a']});
|
'b', {useFactory: (a: string) => `mockB: ${a}`, deps: ['a']});
|
||||||
const ctx =
|
const ctx = TestBed.configureTestingModule({declarations: [MyComp]})
|
||||||
TestBed.configureTestingModule({declarations: [MyComp]}).createComponent(MyComp);
|
.createComponent(MyComp);
|
||||||
|
|
||||||
expect(ctx.debugElement.injector.get('b')).toBe('mockB: aValue');
|
expect(ctx.debugElement.injector.get('b')).toBe('mockB: aValue');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should inject providers that were declared after it', () => {
|
it('should inject providers that were declared after it', () => {
|
||||||
TestBed.overrideProvider(
|
TestBed.overrideProvider(
|
||||||
'a', {useFactory: (b: string) => `mockA: ${b}`, deps: ['b']});
|
'a', {useFactory: (b: string) => `mockA: ${b}`, deps: ['b']});
|
||||||
const ctx =
|
const ctx = TestBed.configureTestingModule({declarations: [MyComp]})
|
||||||
TestBed.configureTestingModule({declarations: [MyComp]}).createComponent(MyComp);
|
.createComponent(MyComp);
|
||||||
|
|
||||||
expect(ctx.debugElement.injector.get('a')).toBe('mockA: bValue');
|
expect(ctx.debugElement.injector.get('a')).toBe('mockA: bValue');
|
||||||
});
|
});
|
||||||
@ -718,6 +723,7 @@ class CompWithUrlTemplate {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('overrideTemplateUsingTestingModule', () => {
|
describe('overrideTemplateUsingTestingModule', () => {
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should compile the template in the context of the testing module', () => {
|
it('should compile the template in the context of the testing module', () => {
|
||||||
@Component({selector: 'comp', template: 'a'})
|
@Component({selector: 'comp', template: 'a'})
|
||||||
class MyComponent {
|
class MyComponent {
|
||||||
@ -746,7 +752,7 @@ class CompWithUrlTemplate {
|
|||||||
expect(testDir !.test).toBe('some prop');
|
expect(testDir !.test).toBe('some prop');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if the TestBed is already created', () => {
|
fixmeIvy('unknown') && it('should throw if the TestBed is already created', () => {
|
||||||
@Component({selector: 'comp', template: 'a'})
|
@Component({selector: 'comp', template: 'a'})
|
||||||
class MyComponent {
|
class MyComponent {
|
||||||
}
|
}
|
||||||
@ -758,6 +764,7 @@ class CompWithUrlTemplate {
|
|||||||
/Cannot override template when the test module has already been instantiated/);
|
/Cannot override template when the test module has already been instantiated/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should reset overrides when the testing module is resetted', () => {
|
it('should reset overrides when the testing module is resetted', () => {
|
||||||
@Component({selector: 'comp', template: 'a'})
|
@Component({selector: 'comp', template: 'a'})
|
||||||
class MyComponent {
|
class MyComponent {
|
||||||
@ -783,24 +790,25 @@ class CompWithUrlTemplate {
|
|||||||
{providers: [{provide: ResourceLoader, useValue: {get: resourceLoaderGet}}]});
|
{providers: [{provide: ResourceLoader, useValue: {get: resourceLoaderGet}}]});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use set up providers', fakeAsync(() => {
|
fixmeIvy('unknown') && it('should use set up providers', fakeAsync(() => {
|
||||||
TestBed.compileComponents();
|
TestBed.compileComponents();
|
||||||
tick();
|
tick();
|
||||||
const compFixture = TestBed.createComponent(CompWithUrlTemplate);
|
const compFixture =
|
||||||
|
TestBed.createComponent(CompWithUrlTemplate);
|
||||||
expect(compFixture.nativeElement).toHaveText('Hello world!');
|
expect(compFixture.nativeElement).toHaveText('Hello world!');
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('useJit true', () => {
|
describe('useJit true', () => {
|
||||||
beforeEach(() => TestBed.configureCompiler({useJit: true}));
|
beforeEach(() => TestBed.configureCompiler({useJit: true}));
|
||||||
it('should set the value into CompilerConfig',
|
fixmeIvy('unknown') && it('should set the value into CompilerConfig',
|
||||||
inject([CompilerConfig], (config: CompilerConfig) => {
|
inject([CompilerConfig], (config: CompilerConfig) => {
|
||||||
expect(config.useJit).toBe(true);
|
expect(config.useJit).toBe(true);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
describe('useJit false', () => {
|
describe('useJit false', () => {
|
||||||
beforeEach(() => TestBed.configureCompiler({useJit: false}));
|
beforeEach(() => TestBed.configureCompiler({useJit: false}));
|
||||||
it('should set the value into CompilerConfig',
|
fixmeIvy('unknown') && it('should set the value into CompilerConfig',
|
||||||
inject([CompilerConfig], (config: CompilerConfig) => {
|
inject([CompilerConfig], (config: CompilerConfig) => {
|
||||||
expect(config.useJit).toBe(false);
|
expect(config.useJit).toBe(false);
|
||||||
}));
|
}));
|
||||||
@ -892,6 +900,7 @@ class CompWithUrlTemplate {
|
|||||||
{providers: [{provide: ResourceLoader, useValue: {get: resourceLoaderGet}}]});
|
{providers: [{provide: ResourceLoader, useValue: {get: resourceLoaderGet}}]});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should report an error for declared components with templateUrl which never call TestBed.compileComponents',
|
it('should report an error for declared components with templateUrl which never call TestBed.compileComponents',
|
||||||
() => {
|
() => {
|
||||||
const itPromise = patchJasmineIt();
|
const itPromise = patchJasmineIt();
|
||||||
@ -910,6 +919,7 @@ class CompWithUrlTemplate {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should error on unknown bound properties on custom elements by default', () => {
|
it('should error on unknown bound properties on custom elements by default', () => {
|
||||||
@Component({template: '<some-element [someUnknownProp]="true"></some-element>'})
|
@Component({template: '<some-element [someUnknownProp]="true"></some-element>'})
|
||||||
class ComponentUsingInvalidProperty {
|
class ComponentUsingInvalidProperty {
|
||||||
@ -918,8 +928,9 @@ class CompWithUrlTemplate {
|
|||||||
const itPromise = patchJasmineIt();
|
const itPromise = patchJasmineIt();
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
() => it(
|
() =>
|
||||||
'should fail', withModule(
|
it('should fail',
|
||||||
|
withModule(
|
||||||
{declarations: [ComponentUsingInvalidProperty]},
|
{declarations: [ComponentUsingInvalidProperty]},
|
||||||
() => TestBed.createComponent(ComponentUsingInvalidProperty))))
|
() => TestBed.createComponent(ComponentUsingInvalidProperty))))
|
||||||
.toThrowError(/Can't bind to 'someUnknownProp'/);
|
.toThrowError(/Can't bind to 'someUnknownProp'/);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user