test(compiler-cli): migrate input/output compliance tests (#39867)

Migrates the `r3_view_compiler_input_outputs` compliance tests to the new format.

PR Close #39867
This commit is contained in:
Kristiyan Kostadinov 2020-11-27 20:47:20 +01:00 committed by Jessica Janiuk
parent 7a5bc95614
commit 97ea2c7bfd
6 changed files with 190 additions and 0 deletions

View File

@ -0,0 +1,99 @@
/****************************************************************************************************
* PARTIAL FILE: component.js
****************************************************************************************************/
import { Component, Input, NgModule, Output } from '@angular/core';
import * as i0 from "@angular/core";
export class MyComponent {
}
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
MyComponent.ɵcmp = i0.ɵɵngDeclareComponent({ version: 1, type: MyComponent, selector: "my-component", inputs: { componentInput: "componentInput", originalComponentInput: ["renamedComponentInput", "originalComponentInput"] }, outputs: { componentOutput: "componentOutput", originalComponentOutput: "renamedComponentOutput" }, ngImport: i0, template: { source: '', isInline: true } });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyComponent, [{
type: Component,
args: [{ selector: 'my-component', template: '' }]
}], null, { componentInput: [{
type: Input
}], originalComponentInput: [{
type: Input,
args: ['renamedComponentInput']
}], componentOutput: [{
type: Output
}], originalComponentOutput: [{
type: Output,
args: ['renamedComponentOutput']
}] }); })();
export class MyModule {
}
MyModule.ɵmod = i0.ɵɵdefineNgModule({ type: MyModule });
MyModule.ɵinj = i0.ɵɵdefineInjector({ factory: function MyModule_Factory(t) { return new (t || MyModule)(); } });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MyModule, { declarations: [MyComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyModule, [{
type: NgModule,
args: [{ declarations: [MyComponent] }]
}], null, null); })();
/****************************************************************************************************
* PARTIAL FILE: component.d.ts
****************************************************************************************************/
import * as i0 from "@angular/core";
export declare class MyComponent {
componentInput: any;
originalComponentInput: any;
componentOutput: any;
originalComponentOutput: any;
static ɵfac: i0.ɵɵFactoryDef<MyComponent, never>;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MyComponent, "my-component", never, { "componentInput": "componentInput"; "originalComponentInput": "renamedComponentInput"; }, { "componentOutput": "componentOutput"; "originalComponentOutput": "renamedComponentOutput"; }, never, never>;
}
export declare class MyModule {
static ɵmod: i0.ɵɵNgModuleDefWithMeta<MyModule, [typeof MyComponent], never, never>;
static ɵinj: i0.ɵɵInjectorDef<MyModule>;
}
/****************************************************************************************************
* PARTIAL FILE: directive.js
****************************************************************************************************/
import { Directive, Input, NgModule, Output } from '@angular/core';
import * as i0 from "@angular/core";
export class MyDirective {
}
MyDirective.ɵfac = function MyDirective_Factory(t) { return new (t || MyDirective)(); };
MyDirective.ɵdir = i0.ɵɵngDeclareDirective({ version: 1, type: MyDirective, selector: "[my-directive]", inputs: { directiveInput: "directiveInput", originalDirectiveInput: ["renamedDirectiveInput", "originalDirectiveInput"] }, outputs: { directiveOutput: "directiveOutput", originalDirectiveOutput: "renamedDirectiveOutput" }, ngImport: i0 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyDirective, [{
type: Directive,
args: [{ selector: '[my-directive]' }]
}], null, { directiveInput: [{
type: Input
}], originalDirectiveInput: [{
type: Input,
args: ['renamedDirectiveInput']
}], directiveOutput: [{
type: Output
}], originalDirectiveOutput: [{
type: Output,
args: ['renamedDirectiveOutput']
}] }); })();
export class MyModule {
}
MyModule.ɵmod = i0.ɵɵdefineNgModule({ type: MyModule });
MyModule.ɵinj = i0.ɵɵdefineInjector({ factory: function MyModule_Factory(t) { return new (t || MyModule)(); } });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MyModule, { declarations: [MyDirective] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyModule, [{
type: NgModule,
args: [{ declarations: [MyDirective] }]
}], null, null); })();
/****************************************************************************************************
* PARTIAL FILE: directive.d.ts
****************************************************************************************************/
import * as i0 from "@angular/core";
export declare class MyDirective {
directiveInput: any;
originalDirectiveInput: any;
directiveOutput: any;
originalDirectiveOutput: any;
static ɵfac: i0.ɵɵFactoryDef<MyDirective, never>;
static ɵdir: i0.ɵɵDirectiveDefWithMeta<MyDirective, "[my-directive]", never, { "directiveInput": "directiveInput"; "originalDirectiveInput": "renamedDirectiveInput"; }, { "directiveOutput": "directiveOutput"; "originalDirectiveOutput": "renamedDirectiveOutput"; }, never>;
}
export declare class MyModule {
static ɵmod: i0.ɵɵNgModuleDefWithMeta<MyModule, [typeof MyDirective], never, never>;
static ɵinj: i0.ɵɵInjectorDef<MyModule>;
}

View File

@ -0,0 +1,39 @@
{
"$schema": "../test_case_schema.json",
"cases": [
{
"description": "should declare inputs/outputs on a component",
"inputFiles": [
"component.ts"
],
"expectations": [
{
"files": [
{
"expected": "component_definition.js",
"generated": "component.js"
}
],
"failureMessage": "Incorrect component definition"
}
]
},
{
"description": "should declare inputs/outputs on a directive",
"inputFiles": [
"directive.ts"
],
"expectations": [
{
"files": [
{
"expected": "directive_definition.js",
"generated": "directive.js"
}
],
"failureMessage": "Incorrect directive definition"
}
]
}
]
}

View File

@ -0,0 +1,14 @@
import {Component, Input, NgModule, Output} from '@angular/core';
@Component({selector: 'my-component', template: ''})
export class MyComponent {
@Input() componentInput: any;
@Input('renamedComponentInput') originalComponentInput: any;
@Output() componentOutput: any;
@Output('renamedComponentOutput') originalComponentOutput: any;
}
@NgModule({declarations: [MyComponent]})
export class MyModule {
}

View File

@ -0,0 +1,12 @@
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
inputs:{
componentInput: "componentInput",
originalComponentInput: ["renamedComponentInput", "originalComponentInput"]
},
outputs: {
componentOutput: "componentOutput",
originalComponentOutput: "renamedComponentOutput"
}
});

View File

@ -0,0 +1,14 @@
import {Directive, Input, NgModule, Output} from '@angular/core';
@Directive({selector: '[my-directive]'})
export class MyDirective {
@Input() directiveInput: any;
@Input('renamedDirectiveInput') originalDirectiveInput: any;
@Output() directiveOutput: any;
@Output('renamedDirectiveOutput') originalDirectiveOutput: any;
}
@NgModule({declarations: [MyDirective]})
export class MyModule {
}

View File

@ -0,0 +1,12 @@
MyDirective.ɵdir = $r3$.ɵɵdefineDirective({
inputs:{
directiveInput: "directiveInput",
originalDirectiveInput: ["renamedDirectiveInput", "originalDirectiveInput"]
},
outputs: {
directiveOutput: "directiveOutput",
originalDirectiveOutput: "renamedDirectiveOutput"
}
});