@@ -17,7 +17,7 @@ describe('scrub-file', () => {
17
17
const clazz = 'var Clazz = (function () { function Clazz() { } return Clazz; }());' ;
18
18
19
19
describe ( 'decorators' , ( ) => {
20
- it ( 'removes Angular decorators' , ( ) => {
20
+ it ( 'removes top-level Angular decorators' , ( ) => {
21
21
const output = stripIndent `
22
22
import { Injectable } from '@angular/core';
23
23
${ clazz }
@@ -31,6 +31,26 @@ describe('scrub-file', () => {
31
31
expect ( oneLine `${ transform ( input ) } ` ) . toEqual ( oneLine `${ output } ` ) ;
32
32
} ) ;
33
33
34
+ it ( 'removes nested Angular decorators' , ( ) => {
35
+ const output = stripIndent `
36
+ import { Injectable } from '@angular/core';
37
+ var Clazz = (function () {
38
+ function Clazz() { }
39
+ return Clazz;
40
+ }());
41
+ ` ;
42
+ const input = stripIndent `
43
+ import { Injectable } from '@angular/core';
44
+ var Clazz = (function () {
45
+ function Clazz() {}
46
+ Clazz.decorators = [ { type: Injectable } ];
47
+ return Clazz;
48
+ }());
49
+ ` ;
50
+
51
+ expect ( oneLine `${ transform ( input ) } ` ) . toEqual ( oneLine `${ output } ` ) ;
52
+ } ) ;
53
+
34
54
it ( 'doesn\'t remove non Angular decorators' , ( ) => {
35
55
const input = stripIndent `
36
56
import { Injectable } from 'another-lib';
@@ -41,7 +61,7 @@ describe('scrub-file', () => {
41
61
expect ( oneLine `${ transform ( input ) } ` ) . toEqual ( oneLine `${ input } ` ) ;
42
62
} ) ;
43
63
44
- it ( 'leaves non-Angulars decorators in mixed arrays' , ( ) => {
64
+ it ( 'leaves non-Angular decorators in mixed arrays' , ( ) => {
45
65
const input = stripIndent `
46
66
import { Injectable } from '@angular/core';
47
67
import { NotInjectable } from 'another-lib';
@@ -60,7 +80,7 @@ describe('scrub-file', () => {
60
80
} ) ;
61
81
62
82
describe ( 'propDecorators' , ( ) => {
63
- it ( 'removes Angular propDecorators' , ( ) => {
83
+ it ( 'removes top-level Angular propDecorators' , ( ) => {
64
84
const output = stripIndent `
65
85
import { Input } from '@angular/core';
66
86
${ clazz }
@@ -74,6 +94,26 @@ describe('scrub-file', () => {
74
94
expect ( oneLine `${ transform ( input ) } ` ) . toEqual ( oneLine `${ output } ` ) ;
75
95
} ) ;
76
96
97
+ it ( 'removes nested Angular propDecorators' , ( ) => {
98
+ const output = stripIndent `
99
+ import { Input } from '@angular/core';
100
+ var Clazz = (function () {
101
+ function Clazz() { }
102
+ return Clazz;
103
+ }());
104
+ ` ;
105
+ const input = stripIndent `
106
+ import { Input } from '@angular/core';
107
+ var Clazz = (function () {
108
+ function Clazz() {}
109
+ Clazz.propDecorators = { 'ngIf': [{ type: Input }] };
110
+ return Clazz;
111
+ }());
112
+ ` ;
113
+
114
+ expect ( oneLine `${ transform ( input ) } ` ) . toEqual ( oneLine `${ output } ` ) ;
115
+ } ) ;
116
+
77
117
it ( 'doesn\'t remove non Angular propDecorators' , ( ) => {
78
118
const input = stripIndent `
79
119
import { Input } from 'another-lib';
@@ -84,7 +124,7 @@ describe('scrub-file', () => {
84
124
expect ( oneLine `${ transform ( input ) } ` ) . toEqual ( oneLine `${ input } ` ) ;
85
125
} ) ;
86
126
87
- it ( 'leaves non-Angulars propDecorators in mixed arrays' , ( ) => {
127
+ it ( 'leaves non-Angular propDecorators in mixed arrays' , ( ) => {
88
128
const output = stripIndent `
89
129
import { Input } from '@angular/core';
90
130
import { NotInput } from 'another-lib';
@@ -121,7 +161,7 @@ describe('scrub-file', () => {
121
161
expect ( oneLine `${ transform ( input ) } ` ) . toEqual ( oneLine `${ output } ` ) ;
122
162
} ) ;
123
163
124
- it ( 'removes non-empty constructor parameters' , ( ) => {
164
+ it ( 'removes non-empty top-level style constructor parameters' , ( ) => {
125
165
const output = stripIndent `
126
166
${ clazz }
127
167
` ;
@@ -133,6 +173,26 @@ describe('scrub-file', () => {
133
173
expect ( oneLine `${ transform ( input ) } ` ) . toEqual ( oneLine `${ output } ` ) ;
134
174
} ) ;
135
175
176
+ it ( 'removes nested constructor parameters' , ( ) => {
177
+ const output = stripIndent `
178
+ import { Injector } from '@angular/core';
179
+ var Clazz = (function () {
180
+ function Clazz() { }
181
+ return Clazz;
182
+ }());
183
+ ` ;
184
+ const input = stripIndent `
185
+ import { Injector } from '@angular/core';
186
+ var Clazz = (function () {
187
+ function Clazz() {}
188
+ Clazz.ctorParameters = function () { return [{type: Injector}]; };
189
+ return Clazz;
190
+ }());
191
+ ` ;
192
+
193
+ expect ( oneLine `${ transform ( input ) } ` ) . toEqual ( oneLine `${ output } ` ) ;
194
+ } ) ;
195
+
136
196
it ( 'doesn\'t remove constructor parameters from whitelisted classes' , ( ) => {
137
197
const input = stripIndent `
138
198
${ clazz . replace ( 'Clazz' , 'PlatformRef_' ) }
0 commit comments