1
1
import * as path from 'path' ;
2
- import { expect } from 'chai' ;
3
2
import { SchematicTestRunner , UnitTestTree } from '@angular-devkit/schematics/testing' ;
4
3
import { Schema as WorkspaceOptions } from '@schematics/angular/workspace/schema' ;
5
4
import { Schema as LibraryOptions } from '@schematics/angular/library/schema' ;
@@ -83,10 +82,6 @@ describe('ng-samurai', () => {
83
82
. toPromise ( ) ;
84
83
}
85
84
86
- function addModelFile ( path : string , content : string ) {
87
- appTree . create ( path , content ) ;
88
- }
89
-
90
85
function removeDefaultLibraryModule ( ) {
91
86
appTree . delete ( '/projects/some-lib/src/lib/some-lib.module.ts' ) ;
92
87
appTree . delete ( '/projects/some-lib/src/lib/some-lib.component.spec.ts' ) ;
@@ -115,7 +110,7 @@ describe('ng-samurai', () => {
115
110
'some-lib/src/lib/bar'
116
111
] ) ;
117
112
118
- expect ( topLevelPublicAPIContent ) . to . equal ( expectedTopLevelPublicAPIContent ) ;
113
+ expect ( topLevelPublicAPIContent ) . toEqual ( expectedTopLevelPublicAPIContent ) ;
119
114
} ) ;
120
115
} ) ;
121
116
@@ -130,17 +125,17 @@ describe('ng-samurai', () => {
130
125
131
126
it ( 'should add a public_api to foo module' , async ( ) => {
132
127
const tree = await runner . runSchematicAsync ( 'ng-samurai' , { } , appTree ) . toPromise ( ) ;
133
- expect ( tree . exists ( '/projects/some-lib/src/lib/foo/public-api.ts' ) ) . to . be . true ;
128
+ expect ( tree . exists ( '/projects/some-lib/src/lib/foo/public-api.ts' ) ) . toBe ( true ) ;
134
129
} ) ;
135
130
136
131
it ( 'should add a public_api to bar module' , async ( ) => {
137
132
const tree = await runner . runSchematicAsync ( 'ng-samurai' , { } , appTree ) . toPromise ( ) ;
138
- expect ( tree . exists ( '/projects/some-lib/src/lib/bar/public-api.ts' ) ) . to . be . true ;
133
+ expect ( tree . exists ( '/projects/some-lib/src/lib/bar/public-api.ts' ) ) . toBe ( true ) ;
139
134
} ) ;
140
135
141
136
it ( 'should not add a public_api to baz module' , async ( ) => {
142
137
const tree = await runner . runSchematicAsync ( 'ng-samurai' , { } , appTree ) . toPromise ( ) ;
143
- expect ( tree . exists ( '/projects/some-lib/src/lib/bar/baz/public-api.ts' ) ) . not . to . be . true ;
138
+ expect ( tree . exists ( '/projects/some-lib/src/lib/bar/baz/public-api.ts' ) ) . not . toBe ( true ) ;
144
139
} ) ;
145
140
146
141
it ( 'should export foo.component.ts and foo.module.ts from foos public-api' , async ( ) => {
@@ -151,7 +146,7 @@ describe('ng-samurai', () => {
151
146
expectedFilesIncludedInPublicAPI
152
147
) ;
153
148
154
- expect ( publicAPI ) . to . equal ( expectedFileContent ) ;
149
+ expect ( publicAPI ) . toEqual ( expectedFileContent ) ;
155
150
} ) ;
156
151
157
152
it ( 'should export bar.component.ts, bar.module.ts, bar.model and baz.component.ts from bars public-api' , async ( ) => {
@@ -167,46 +162,46 @@ describe('ng-samurai', () => {
167
162
expectedFilesIncludedInPublicAPI
168
163
) ;
169
164
170
- expect ( publicAPI ) . to . equal ( expectedFileContent ) ;
165
+ expect ( publicAPI ) . toEqual ( expectedFileContent ) ;
171
166
} ) ;
172
167
} ) ;
173
168
} ) ;
174
169
175
170
describe ( 'index.ts' , ( ) => {
176
171
it ( 'should add an index.ts to foo module' , async ( ) => {
177
172
const tree = await runner . runSchematicAsync ( 'ng-samurai' , { } , appTree ) . toPromise ( ) ;
178
- expect ( tree . exists ( '/projects/some-lib/src/lib/foo/index.ts' ) ) . to . be . true ;
173
+ expect ( tree . exists ( '/projects/some-lib/src/lib/foo/index.ts' ) ) . toBe ( true ) ;
179
174
} ) ;
180
175
181
176
it ( 'should add export everything from public-api inside the index.ts of foo' , async ( ) => {
182
177
const tree = await runner . runSchematicAsync ( 'ng-samurai' , { } , appTree ) . toPromise ( ) ;
183
- expect ( tree . read ( '/projects/some-lib/src/lib/foo/index.ts' ) . toString ( ) ) . to . equal (
178
+ expect ( tree . read ( '/projects/some-lib/src/lib/foo/index.ts' ) . toString ( ) ) . toEqual (
184
179
"export * from './public-api';\n"
185
180
) ;
186
181
} ) ;
187
182
188
183
it ( 'should add an index.ts bar module' , async ( ) => {
189
184
const tree = await runner . runSchematicAsync ( 'ng-samurai' , { } , appTree ) . toPromise ( ) ;
190
- expect ( tree . exists ( '/projects/some-lib/src/lib/bar/index.ts' ) ) . to . be . true ;
185
+ expect ( tree . exists ( '/projects/some-lib/src/lib/bar/index.ts' ) ) . toBe ( true ) ;
191
186
} ) ;
192
187
193
188
it ( 'should add export everything from public-api inside the index.ts of bar' , async ( ) => {
194
189
const tree = await runner . runSchematicAsync ( 'ng-samurai' , { } , appTree ) . toPromise ( ) ;
195
- expect ( tree . read ( '/projects/some-lib/src/lib/bar/index.ts' ) . toString ( ) ) . to . equal (
190
+ expect ( tree . read ( '/projects/some-lib/src/lib/bar/index.ts' ) . toString ( ) ) . toEqual (
196
191
"export * from './public-api';\n"
197
192
) ;
198
193
} ) ;
199
194
200
195
it ( 'should not add an index.ts to baz module' , async ( ) => {
201
196
const tree = await runner . runSchematicAsync ( 'ng-samurai' , { } , appTree ) . toPromise ( ) ;
202
- expect ( tree . exists ( '/projects/some-lib/src/lib/bar/baz/index.ts' ) ) . not . to . be . true ;
197
+ expect ( tree . exists ( '/projects/some-lib/src/lib/bar/baz/index.ts' ) ) . not . toBe ( true ) ;
203
198
} ) ;
204
199
} ) ;
205
200
206
201
describe ( 'package.json' , ( ) => {
207
202
it ( 'should add an index.ts to foo module' , async ( ) => {
208
203
const tree = await runner . runSchematicAsync ( 'ng-samurai' , { } , appTree ) . toPromise ( ) ;
209
- expect ( tree . exists ( '/projects/some-lib/src/lib/foo/package.json' ) ) . to . be . true ;
204
+ expect ( tree . exists ( '/projects/some-lib/src/lib/foo/package.json' ) ) . toBe ( true ) ;
210
205
} ) ;
211
206
212
207
it ( 'should add the correct config to the package.json of foo subentry' , async ( ) => {
@@ -221,12 +216,12 @@ describe('ng-samurai', () => {
221
216
const subEntryConfig = JSON . parse (
222
217
tree . read ( '/projects/some-lib/src/lib/foo/package.json' ) . toString ( )
223
218
) ;
224
- expect ( subEntryConfig ) . to . eql ( expectedSubentryConfig ) ;
219
+ expect ( subEntryConfig ) . toEqual ( expectedSubentryConfig ) ;
225
220
} ) ;
226
221
227
222
it ( 'should add an packag.json to bar module' , async ( ) => {
228
223
const tree = await runner . runSchematicAsync ( 'ng-samurai' , { } , appTree ) . toPromise ( ) ;
229
- expect ( tree . exists ( '/projects/some-lib/src/lib/bar/package.json' ) ) . to . be . true ;
224
+ expect ( tree . exists ( '/projects/some-lib/src/lib/bar/package.json' ) ) . toBe ( true ) ;
230
225
} ) ;
231
226
232
227
it ( 'should add the correct config to the package.json of bar subentry' , async ( ) => {
@@ -241,12 +236,12 @@ describe('ng-samurai', () => {
241
236
const subEntryConfig = JSON . parse (
242
237
tree . read ( '/projects/some-lib/src/lib/bar/package.json' ) . toString ( )
243
238
) ;
244
- expect ( subEntryConfig ) . to . eql ( expectedSubentryConfig ) ;
239
+ expect ( subEntryConfig ) . toEqual ( expectedSubentryConfig ) ;
245
240
} ) ;
246
241
247
242
it ( 'should not add a package.json to baz module' , async ( ) => {
248
243
const tree = await runner . runSchematicAsync ( 'ng-samurai' , { } , appTree ) . toPromise ( ) ;
249
- expect ( tree . exists ( '/projects/some-lib/src/lib/bar/baz/package.json' ) ) . not . to . be . true ;
244
+ expect ( tree . exists ( '/projects/some-lib/src/lib/bar/baz/package.json' ) ) . not . toBe ( true ) ;
250
245
} ) ;
251
246
} ) ;
252
247
@@ -293,7 +288,7 @@ describe('ng-samurai', () => {
293
288
'/projects/some-lib/src/lib/bar/bar.module.ts'
294
289
) ;
295
290
296
- expect ( moduleContentAfterSchematics ) . to . equal ( expectedModuleContent ) ;
291
+ expect ( moduleContentAfterSchematics ) . toEqual ( expectedModuleContent ) ;
297
292
} ) ;
298
293
299
294
it ( 'should not update the baz components content since the import paths do not need to be updated' , async ( ) => {
@@ -306,7 +301,7 @@ describe('ng-samurai', () => {
306
301
'/projects/some-lib/src/lib/bar/baz/baz.component.ts'
307
302
) ;
308
303
309
- expect ( componentContentAfterSchematics ) . to . equal ( expectedComponentContent ) ;
304
+ expect ( componentContentAfterSchematics ) . toEqual ( expectedComponentContent ) ;
310
305
} ) ;
311
306
} ) ;
312
307
@@ -326,7 +321,7 @@ describe('ng-samurai', () => {
326
321
} ;
327
322
328
323
const paths = tsconfigContent . compilerOptions . paths ;
329
- expect ( paths ) . to . eql ( expectedPaths ) ;
324
+ expect ( paths ) . toEqual ( expectedPaths ) ;
330
325
} ) ;
331
326
332
327
it ( 'should add paths to the tsconfig.json even if no path exist' , async ( ) => {
@@ -338,7 +333,7 @@ describe('ng-samurai', () => {
338
333
} ;
339
334
340
335
const paths = tsconfigContent . compilerOptions . paths ;
341
- expect ( paths ) . to . eql ( expectedPaths ) ;
336
+ expect ( paths ) . toEqual ( expectedPaths ) ;
342
337
} ) ;
343
338
} ) ;
344
339
} ) ;
0 commit comments