@@ -56,6 +56,25 @@ describe('Pipe Schematic', () => {
56
56
it ( 'should create a pipe' , async ( ) => {
57
57
const tree = await schematicRunner . runSchematic ( 'pipe' , defaultNonStandaloneOptions , appTree ) ;
58
58
const files = tree . files ;
59
+ expect ( files ) . toContain ( '/projects/bar/src/app/foo-pipe.spec.ts' ) ;
60
+ expect ( files ) . toContain ( '/projects/bar/src/app/foo-pipe.ts' ) ;
61
+ const moduleContent = getFileContent ( tree , '/projects/bar/src/app/app.module.ts' ) ;
62
+ expect ( moduleContent ) . toMatch ( / i m p o r t .* F o o .* f r o m ' .\/ f o o - p i p e ' / ) ;
63
+ expect ( moduleContent ) . toMatch ( / d e c l a r a t i o n s : \s * \[ [ ^ \] ] + ?, \r ? \n \s + F o o P i p e \r ? \n / m) ;
64
+ const fileContent = tree . readContent ( '/projects/bar/src/app/foo-pipe.ts' ) ;
65
+ expect ( fileContent ) . toContain ( 'transform(value: unknown, ...args: unknown[])' ) ;
66
+ } ) ;
67
+
68
+ it ( 'should use a `.` type separator when specified' , async ( ) => {
69
+ const tree = await schematicRunner . runSchematic (
70
+ 'pipe' ,
71
+ {
72
+ ...defaultNonStandaloneOptions ,
73
+ typeSeparator : '.' ,
74
+ } ,
75
+ appTree ,
76
+ ) ;
77
+ const files = tree . files ;
59
78
expect ( files ) . toContain ( '/projects/bar/src/app/foo.pipe.spec.ts' ) ;
60
79
expect ( files ) . toContain ( '/projects/bar/src/app/foo.pipe.ts' ) ;
61
80
const moduleContent = getFileContent ( tree , '/projects/bar/src/app/app.module.ts' ) ;
@@ -65,13 +84,32 @@ describe('Pipe Schematic', () => {
65
84
expect ( fileContent ) . toContain ( 'transform(value: unknown, ...args: unknown[])' ) ;
66
85
} ) ;
67
86
87
+ it ( 'should use a `-` type separator when specified' , async ( ) => {
88
+ const tree = await schematicRunner . runSchematic (
89
+ 'pipe' ,
90
+ {
91
+ ...defaultNonStandaloneOptions ,
92
+ typeSeparator : '-' ,
93
+ } ,
94
+ appTree ,
95
+ ) ;
96
+ const files = tree . files ;
97
+ expect ( files ) . toContain ( '/projects/bar/src/app/foo-pipe.spec.ts' ) ;
98
+ expect ( files ) . toContain ( '/projects/bar/src/app/foo-pipe.ts' ) ;
99
+ const moduleContent = getFileContent ( tree , '/projects/bar/src/app/app.module.ts' ) ;
100
+ expect ( moduleContent ) . toMatch ( / i m p o r t .* F o o .* f r o m ' .\/ f o o - p i p e ' / ) ;
101
+ expect ( moduleContent ) . toMatch ( / d e c l a r a t i o n s : \s * \[ [ ^ \] ] + ?, \r ? \n \s + F o o P i p e \r ? \n / m) ;
102
+ const fileContent = tree . readContent ( '/projects/bar/src/app/foo-pipe.ts' ) ;
103
+ expect ( fileContent ) . toContain ( 'transform(value: unknown, ...args: unknown[])' ) ;
104
+ } ) ;
105
+
68
106
it ( 'should import into a specified module' , async ( ) => {
69
107
const options = { ...defaultNonStandaloneOptions , module : 'app.module.ts' } ;
70
108
71
109
const tree = await schematicRunner . runSchematic ( 'pipe' , options , appTree ) ;
72
110
const appModule = getFileContent ( tree , '/projects/bar/src/app/app.module.ts' ) ;
73
111
74
- expect ( appModule ) . toMatch ( / i m p o r t { F o o P i p e } f r o m ' .\/ f o o . p i p e ' / ) ;
112
+ expect ( appModule ) . toMatch ( / i m p o r t { F o o P i p e } f r o m ' .\/ f o o - p i p e ' / ) ;
75
113
} ) ;
76
114
77
115
it ( 'should fail if specified module does not exist' , async ( ) => {
@@ -94,7 +132,7 @@ describe('Pipe Schematic', () => {
94
132
appTree = await schematicRunner . runSchematic ( 'pipe' , options , appTree ) ;
95
133
96
134
const content = appTree . readContent ( '/projects/bar/src/app/admin/module/module.module.ts' ) ;
97
- expect ( content ) . toMatch ( / i m p o r t { F o o P i p e } f r o m ' \. \. \/ \. \. \/ f o o . p i p e ' / ) ;
135
+ expect ( content ) . toMatch ( / i m p o r t { F o o P i p e } f r o m ' \. \. \/ \. \. \/ f o o - p i p e ' / ) ;
98
136
} ) ;
99
137
100
138
it ( 'should export the pipe' , async ( ) => {
@@ -110,10 +148,10 @@ describe('Pipe Schematic', () => {
110
148
111
149
const tree = await schematicRunner . runSchematic ( 'pipe' , options , appTree ) ;
112
150
const files = tree . files ;
113
- expect ( files ) . toContain ( '/projects/bar/src/app/foo/foo. pipe.spec.ts' ) ;
114
- expect ( files ) . toContain ( '/projects/bar/src/app/foo/foo. pipe.ts' ) ;
151
+ expect ( files ) . toContain ( '/projects/bar/src/app/foo/foo- pipe.spec.ts' ) ;
152
+ expect ( files ) . toContain ( '/projects/bar/src/app/foo/foo- pipe.ts' ) ;
115
153
const moduleContent = getFileContent ( tree , '/projects/bar/src/app/app.module.ts' ) ;
116
- expect ( moduleContent ) . toMatch ( / i m p o r t .* F o o .* f r o m ' .\/ f o o \/ f o o . p i p e ' / ) ;
154
+ expect ( moduleContent ) . toMatch ( / i m p o r t .* F o o .* f r o m ' .\/ f o o \/ f o o - p i p e ' / ) ;
117
155
expect ( moduleContent ) . toMatch ( / d e c l a r a t i o n s : \s * \[ [ ^ \] ] + ?, \r ? \n \s + F o o P i p e \r ? \n / m) ;
118
156
} ) ;
119
157
@@ -124,7 +162,7 @@ describe('Pipe Schematic', () => {
124
162
const options = { ...defaultNonStandaloneOptions , module : routingFileName } ;
125
163
const tree = await schematicRunner . runSchematic ( 'pipe' , options , newTree ) ;
126
164
const content = getFileContent ( tree , routingModulePath ) ;
127
- expect ( content ) . toMatch ( / i m p o r t { F o o P i p e } f r o m ' .\/ f o o . p i p e / ) ;
165
+ expect ( content ) . toMatch ( / i m p o r t { F o o P i p e } f r o m ' .\/ f o o - p i p e / ) ;
128
166
} ) ;
129
167
130
168
it ( 'should respect the sourceRoot value' , async ( ) => {
@@ -143,7 +181,7 @@ describe('Pipe Schematic', () => {
143
181
'/projects/bar/custom/app/app.module.ts' ,
144
182
) ;
145
183
appTree = await schematicRunner . runSchematic ( 'pipe' , defaultNonStandaloneOptions , appTree ) ;
146
- expect ( appTree . files ) . toContain ( '/projects/bar/custom/app/foo. pipe.ts' ) ;
184
+ expect ( appTree . files ) . toContain ( '/projects/bar/custom/app/foo- pipe.ts' ) ;
147
185
} ) ;
148
186
} ) ;
149
187
@@ -155,7 +193,7 @@ describe('Pipe Schematic', () => {
155
193
it ( 'should create a standalone pipe' , async ( ) => {
156
194
const tree = await schematicRunner . runSchematic ( 'pipe' , defaultOptions , appTree ) ;
157
195
const moduleContent = tree . readContent ( '/projects/bar/src/app/app.module.ts' ) ;
158
- const pipeContent = tree . readContent ( '/projects/bar/src/app/foo. pipe.ts' ) ;
196
+ const pipeContent = tree . readContent ( '/projects/bar/src/app/foo- pipe.ts' ) ;
159
197
expect ( pipeContent ) . not . toContain ( 'standalone' ) ;
160
198
expect ( pipeContent ) . toContain ( 'class FooPipe' ) ;
161
199
expect ( moduleContent ) . not . toContain ( 'FooPipe' ) ;
@@ -166,8 +204,8 @@ describe('Pipe Schematic', () => {
166
204
167
205
const tree = await schematicRunner . runSchematic ( 'pipe' , options , appTree ) ;
168
206
const files = tree . files ;
169
- expect ( files ) . not . toContain ( '/projects/bar/src/app/foo. pipe.spec.ts' ) ;
170
- expect ( files ) . toContain ( '/projects/bar/src/app/foo. pipe.ts' ) ;
207
+ expect ( files ) . not . toContain ( '/projects/bar/src/app/foo- pipe.spec.ts' ) ;
208
+ expect ( files ) . toContain ( '/projects/bar/src/app/foo- pipe.ts' ) ;
171
209
} ) ;
172
210
173
211
it ( 'should error when class name contains invalid characters' , async ( ) => {
0 commit comments