1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var path_1 = require("path");
|
4 | var fs = require("fs");
|
5 | var Constants = require("../util/constants");
|
6 | var helpers = require("../util/helpers");
|
7 | var globUtils = require("../util/glob-util");
|
8 | var util = require("./util");
|
9 | var GeneratorConstants = require("./constants");
|
10 | describe('util', function () {
|
11 | describe('hydrateRequest', function () {
|
12 | it('should take a component request and return a hydrated component request', function () {
|
13 |
|
14 | var baseDir = path_1.join(process.cwd(), 'someDir', 'project');
|
15 | var componentsDir = path_1.join(baseDir, 'src', 'components');
|
16 | var context = {
|
17 | componentsDir: componentsDir
|
18 | };
|
19 | var request = {
|
20 | type: Constants.COMPONENT,
|
21 | name: 'settings view',
|
22 | includeSpec: true,
|
23 | includeNgModule: true
|
24 | };
|
25 | var templateDir = path_1.join(baseDir, 'node_modules', 'ionic-angular', 'templates');
|
26 | spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(templateDir);
|
27 |
|
28 | var hydratedRequest = util.hydrateRequest(context, request);
|
29 |
|
30 | expect(hydratedRequest).toEqual({
|
31 | className: 'SettingsViewComponent',
|
32 | dirToRead: path_1.join(templateDir, 'component'),
|
33 | dirToWrite: path_1.join(componentsDir, 'settings-view'),
|
34 | fileName: 'settings-view',
|
35 | importStatement: 'import { IonicPage, NavController, NavParams } from \'ionic-angular\';',
|
36 | includeNgModule: true,
|
37 | includeSpec: true,
|
38 | ionicPage: '\n@IonicPage()',
|
39 | name: 'settings view',
|
40 | type: 'component'
|
41 | });
|
42 | expect(hydratedRequest.type).toEqual(Constants.COMPONENT);
|
43 | expect(hydratedRequest.name).toEqual(request.name);
|
44 | expect(hydratedRequest.includeNgModule).toBeTruthy();
|
45 | expect(hydratedRequest.includeSpec).toBeTruthy();
|
46 | expect(hydratedRequest.className).toEqual('SettingsViewComponent');
|
47 | expect(hydratedRequest.fileName).toEqual('settings-view');
|
48 | expect(hydratedRequest.dirToRead).toEqual(path_1.join(templateDir, Constants.COMPONENT));
|
49 | expect(hydratedRequest.dirToWrite).toEqual(path_1.join(componentsDir, hydratedRequest.fileName));
|
50 | });
|
51 | it('should take a page request and return a hydrated page request', function () {
|
52 |
|
53 | var baseDir = path_1.join(process.cwd(), 'someDir', 'project');
|
54 | var pagesDir = path_1.join(baseDir, 'src', 'pages');
|
55 | var context = {
|
56 | pagesDir: pagesDir
|
57 | };
|
58 | var request = {
|
59 | type: Constants.PAGE,
|
60 | name: 'settings view',
|
61 | includeSpec: true,
|
62 | includeNgModule: true
|
63 | };
|
64 | var templateDir = path_1.join(baseDir, 'node_modules', 'ionic-angular', 'templates');
|
65 | spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(templateDir);
|
66 |
|
67 | var hydratedRequest = util.hydrateRequest(context, request);
|
68 |
|
69 | expect(hydratedRequest).toEqual({
|
70 | className: 'SettingsViewPage',
|
71 | dirToRead: path_1.join(templateDir, 'page'),
|
72 | dirToWrite: path_1.join(pagesDir, 'settings-view'),
|
73 | fileName: 'settings-view',
|
74 | importStatement: 'import { IonicPage, NavController, NavParams } from \'ionic-angular\';',
|
75 | includeNgModule: true,
|
76 | includeSpec: true,
|
77 | ionicPage: '\n@IonicPage()',
|
78 | name: 'settings view',
|
79 | type: 'page'
|
80 | });
|
81 | expect(hydratedRequest.type).toEqual(Constants.PAGE);
|
82 | expect(hydratedRequest.name).toEqual(request.name);
|
83 | expect(hydratedRequest.includeNgModule).toBeTruthy();
|
84 | expect(hydratedRequest.includeSpec).toBeTruthy();
|
85 | expect(hydratedRequest.className).toEqual('SettingsViewPage');
|
86 | expect(hydratedRequest.fileName).toEqual('settings-view');
|
87 | expect(hydratedRequest.dirToRead).toEqual(path_1.join(templateDir, Constants.PAGE));
|
88 | expect(hydratedRequest.dirToWrite).toEqual(path_1.join(pagesDir, hydratedRequest.fileName));
|
89 | });
|
90 | it('should take a page with no module request and return a hydrated page request', function () {
|
91 |
|
92 | var baseDir = path_1.join(process.cwd(), 'someDir', 'project');
|
93 | var pagesDir = path_1.join(baseDir, 'src', 'pages');
|
94 | var context = {
|
95 | pagesDir: pagesDir
|
96 | };
|
97 | var includeNgModule = false;
|
98 | var request = {
|
99 | type: Constants.PAGE,
|
100 | name: 'about',
|
101 | includeSpec: true,
|
102 | includeNgModule: false
|
103 | };
|
104 | var templateDir = path_1.join(baseDir, 'node_modules', 'ionic-angular', 'templates');
|
105 | spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(templateDir);
|
106 |
|
107 | var hydratedRequest = util.hydrateRequest(context, request);
|
108 |
|
109 | expect(hydratedRequest).toEqual({
|
110 | className: 'AboutPage',
|
111 | dirToRead: path_1.join(templateDir, 'page'),
|
112 | dirToWrite: path_1.join(pagesDir, 'about'),
|
113 | fileName: 'about',
|
114 | importStatement: 'import { NavController, NavParams } from \'ionic-angular\';',
|
115 | includeNgModule: false,
|
116 | includeSpec: true,
|
117 | ionicPage: null,
|
118 | name: 'about',
|
119 | type: 'page'
|
120 | });
|
121 | expect(hydratedRequest.ionicPage).toEqual(null);
|
122 | expect(hydratedRequest.importStatement).toEqual('import { NavController, NavParams } from \'ionic-angular\';');
|
123 | expect(hydratedRequest.type).toEqual(Constants.PAGE);
|
124 | expect(hydratedRequest.name).toEqual(request.name);
|
125 | expect(hydratedRequest.includeNgModule).toBeFalsy();
|
126 | expect(hydratedRequest.includeSpec).toBeTruthy();
|
127 | expect(hydratedRequest.className).toEqual('AboutPage');
|
128 | expect(hydratedRequest.fileName).toEqual('about');
|
129 | expect(hydratedRequest.dirToRead).toEqual(path_1.join(templateDir, Constants.PAGE));
|
130 | expect(hydratedRequest.dirToWrite).toEqual(path_1.join(pagesDir, hydratedRequest.fileName));
|
131 | });
|
132 | });
|
133 | describe('hydrateTabRequest', function () {
|
134 | it('should take a lazy loaded page set the tab root to a string', function () {
|
135 |
|
136 | var baseDir = path_1.join(process.cwd(), 'someDir', 'project');
|
137 | var pagesDir = path_1.join(baseDir, 'src', 'pages');
|
138 | var templateDir = path_1.join(baseDir, 'node_modules', 'ionic-angular', 'templates');
|
139 | var context = { pagesDir: pagesDir };
|
140 | var request = {
|
141 | type: 'tabs',
|
142 | name: 'stooges',
|
143 | includeNgModule: true,
|
144 | tabs: [
|
145 | {
|
146 | includeNgModule: true,
|
147 | type: 'page',
|
148 | name: 'moe',
|
149 | className: 'MoePage',
|
150 | fileName: 'moe',
|
151 | dirToRead: path_1.join(templateDir, 'page'),
|
152 | dirToWrite: path_1.join(pagesDir, 'moe')
|
153 | }
|
154 | ]
|
155 | };
|
156 | spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(templateDir);
|
157 |
|
158 | var hydatedTabRequest = util.hydrateTabRequest(context, request);
|
159 |
|
160 | expect(hydatedTabRequest.tabVariables).toEqual(" moeRoot = 'MoePage'\n");
|
161 | });
|
162 | it('should take a page set the tab root to a component ref', function () {
|
163 |
|
164 | var baseDir = path_1.join(process.cwd(), 'someDir', 'project');
|
165 | var pagesDir = path_1.join(baseDir, 'src', 'pages');
|
166 | var templateDir = path_1.join(baseDir, 'node_modules', 'ionic-angular', 'templates');
|
167 | var context = { pagesDir: pagesDir };
|
168 | var request = {
|
169 | type: 'tabs',
|
170 | name: 'stooges',
|
171 | includeNgModule: false,
|
172 | tabs: [
|
173 | {
|
174 | includeNgModule: false,
|
175 | type: 'page',
|
176 | name: 'moe',
|
177 | className: 'MoePage',
|
178 | fileName: 'moe',
|
179 | dirToRead: path_1.join(templateDir, 'page'),
|
180 | dirToWrite: path_1.join(pagesDir, 'moe')
|
181 | }
|
182 | ]
|
183 | };
|
184 | spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(templateDir);
|
185 |
|
186 | var hydatedTabRequest = util.hydrateTabRequest(context, request);
|
187 |
|
188 | expect(hydatedTabRequest.tabVariables).toEqual(' moeRoot = MoePage\n');
|
189 | });
|
190 | });
|
191 | describe('readTemplates', function () {
|
192 | it('should get a map of templates and their content back', function () {
|
193 |
|
194 | var templateDir = '/Users/noone/project/node_modules/ionic-angular/templates/component';
|
195 | var knownValues = [
|
196 | 'html.tmpl',
|
197 | 'scss.tmpl',
|
198 | 'spec.ts.tmpl',
|
199 | 'ts.tmpl',
|
200 | 'module.tmpl'
|
201 | ];
|
202 | var fileContent = 'SomeContent';
|
203 | spyOn(fs, 'readdirSync').and.returnValue(knownValues);
|
204 | spyOn(helpers, helpers.readFileAsync.name).and.returnValue(Promise.resolve(fileContent));
|
205 |
|
206 | var promise = util.readTemplates(templateDir);
|
207 |
|
208 | return promise.then(function (map) {
|
209 | expect(map.get(path_1.join(templateDir, knownValues[0]))).toEqual(fileContent);
|
210 | expect(map.get(path_1.join(templateDir, knownValues[1]))).toEqual(fileContent);
|
211 | expect(map.get(path_1.join(templateDir, knownValues[2]))).toEqual(fileContent);
|
212 | expect(map.get(path_1.join(templateDir, knownValues[3]))).toEqual(fileContent);
|
213 | expect(map.get(path_1.join(templateDir, knownValues[4]))).toEqual(fileContent);
|
214 | });
|
215 | });
|
216 | });
|
217 | describe('filterOutTemplates', function () {
|
218 | it('should preserve all templates', function () {
|
219 | var map = new Map();
|
220 | var templateDir = '/Users/noone/project/node_modules/ionic-angular/templates/component';
|
221 | var fileContent = 'SomeContent';
|
222 | var knownValues = [
|
223 | 'html.tmpl',
|
224 | 'scss.tmpl',
|
225 | 'spec.ts.tmpl',
|
226 | 'ts.tmpl',
|
227 | 'module.tmpl'
|
228 | ];
|
229 | map.set(path_1.join(templateDir, knownValues[0]), fileContent);
|
230 | map.set(path_1.join(templateDir, knownValues[1]), fileContent);
|
231 | map.set(path_1.join(templateDir, knownValues[2]), fileContent);
|
232 | map.set(path_1.join(templateDir, knownValues[3]), fileContent);
|
233 | map.set(path_1.join(templateDir, knownValues[4]), fileContent);
|
234 | var newMap = util.filterOutTemplates({ includeNgModule: true, includeSpec: true }, map);
|
235 | expect(newMap.size).toEqual(knownValues.length);
|
236 | });
|
237 | it('should remove spec', function () {
|
238 | var map = new Map();
|
239 | var templateDir = '/Users/noone/project/node_modules/ionic-angular/templates/component';
|
240 | var fileContent = 'SomeContent';
|
241 | var knownValues = [
|
242 | 'html.tmpl',
|
243 | 'scss.tmpl',
|
244 | 'spec.ts.tmpl',
|
245 | 'ts.tmpl',
|
246 | 'module.tmpl'
|
247 | ];
|
248 | map.set(path_1.join(templateDir, knownValues[0]), fileContent);
|
249 | map.set(path_1.join(templateDir, knownValues[1]), fileContent);
|
250 | map.set(path_1.join(templateDir, knownValues[2]), fileContent);
|
251 | map.set(path_1.join(templateDir, knownValues[3]), fileContent);
|
252 | map.set(path_1.join(templateDir, knownValues[4]), fileContent);
|
253 | var newMap = util.filterOutTemplates({ includeNgModule: true, includeSpec: false }, map);
|
254 | expect(newMap.size).toEqual(4);
|
255 | expect(newMap.get(path_1.join(templateDir, knownValues[0]))).toBeTruthy();
|
256 | expect(newMap.get(path_1.join(templateDir, knownValues[1]))).toBeTruthy();
|
257 | expect(newMap.get(path_1.join(templateDir, knownValues[2]))).toBeFalsy();
|
258 | expect(newMap.get(path_1.join(templateDir, knownValues[3]))).toBeTruthy();
|
259 | expect(newMap.get(path_1.join(templateDir, knownValues[4]))).toBeTruthy();
|
260 | });
|
261 | it('should remove spec and module', function () {
|
262 | var map = new Map();
|
263 | var templateDir = '/Users/noone/project/node_modules/ionic-angular/templates/component';
|
264 | var fileContent = 'SomeContent';
|
265 | var knownValues = [
|
266 | 'html.tmpl',
|
267 | 'scss.tmpl',
|
268 | 'spec.ts.tmpl',
|
269 | 'ts.tmpl',
|
270 | 'module.ts.tmpl'
|
271 | ];
|
272 | map.set(path_1.join(templateDir, knownValues[0]), fileContent);
|
273 | map.set(path_1.join(templateDir, knownValues[1]), fileContent);
|
274 | map.set(path_1.join(templateDir, knownValues[2]), fileContent);
|
275 | map.set(path_1.join(templateDir, knownValues[3]), fileContent);
|
276 | map.set(path_1.join(templateDir, knownValues[4]), fileContent);
|
277 | var newMap = util.filterOutTemplates({ includeNgModule: false, includeSpec: false }, map);
|
278 | expect(newMap.size).toEqual(3);
|
279 | expect(newMap.get(path_1.join(templateDir, knownValues[0]))).toBeTruthy();
|
280 | expect(newMap.get(path_1.join(templateDir, knownValues[1]))).toBeTruthy();
|
281 | expect(newMap.get(path_1.join(templateDir, knownValues[2]))).toBeFalsy();
|
282 | expect(newMap.get(path_1.join(templateDir, knownValues[3]))).toBeTruthy();
|
283 | expect(newMap.get(path_1.join(templateDir, knownValues[4]))).toBeFalsy();
|
284 | });
|
285 | });
|
286 | describe('applyTemplates', function () {
|
287 | it('should replace the template content', function () {
|
288 | var fileOne = '/Users/noone/fileOne';
|
289 | var fileOneContent = "\n<!--\n Generated template for the $CLASSNAME component.\n\n See https://angular.io/docs/ts/latest/api/core/index/ComponentMetadata-class.html\n for more info on Angular 2 Components.\n-->\n\n{{text}}\n\n ";
|
290 | var fileTwo = '/Users/noone/fileTwo';
|
291 | var fileTwoContent = "\n$FILENAME {\n\n}\n ";
|
292 | var fileThree = '/Users/noone/fileThree';
|
293 | var fileThreeContent = "\ndescribe('$CLASSNAME', () => {\n it('should do something', () => {\n expect(true).toEqual(true);\n });\n});\n ";
|
294 | var fileFour = '/Users/noone/fileFour';
|
295 | var fileFourContent = "\nimport { Component } from '@angular/core';\n\n/*\n Generated class for the $CLASSNAME component.\n\n See https://angular.io/docs/ts/latest/api/core/index/ComponentMetadata-class.html\n for more info on Angular 2 Components.\n*/\n@Component({\n selector: '$FILENAME',\n templateUrl: '$FILENAME.html'\n})\nexport class $CLASSNAMEComponent {\n\n text: string;\n\n constructor() {\n console.log('Hello $CLASSNAME Component');\n this.text = 'Hello World';\n }\n\n}\n\n ";
|
296 | var fileFive = '/Users/noone/fileFive';
|
297 | var fileFiveContent = "\nimport { NgModule } from '@angular/core';\nimport { $CLASSNAME } from './$FILENAME';\nimport { IonicModule } from 'ionic-angular';\n\n@NgModule({\n declarations: [\n $CLASSNAME,\n ],\n imports: [\n IonicModule.forChild($CLASSNAME)\n ],\n entryComponents: [\n $CLASSNAME\n ],\n providers: []\n})\nexport class $CLASSNAMEModule {}\n ";
|
298 | var fileSix = '/Users/noone/fileSix';
|
299 | var fileSixContent = "\n<!--\n Generated template for the $CLASSNAME page.\n\n See http://ionicframework.com/docs/v2/components/#navigation for more info on\n Ionic pages and navigation.\n-->\n<ion-header>\n\n <ion-navbar>\n <ion-title>$SUPPLIEDNAME</ion-title>\n </ion-navbar>\n\n</ion-header>\n\n\n<ion-content padding>\n\n</ion-content>\n ";
|
300 | var fileSeven = '/Users/noone/fileSeven';
|
301 | var fileSevenContent = "\n<ion-tabs>\n$TAB_CONTENT\n</ion-tabs>\n ";
|
302 | var map = new Map();
|
303 | map.set(fileOne, fileOneContent);
|
304 | map.set(fileTwo, fileTwoContent);
|
305 | map.set(fileThree, fileThreeContent);
|
306 | map.set(fileFour, fileFourContent);
|
307 | map.set(fileFive, fileFiveContent);
|
308 | map.set(fileSix, fileSixContent);
|
309 | map.set(fileSeven, fileSevenContent);
|
310 | var className = 'SettingsView';
|
311 | var fileName = 'settings-view';
|
312 | var suppliedName = 'settings view';
|
313 | var results = util.applyTemplates({ name: suppliedName, className: className, fileName: fileName }, map);
|
314 | var modifiedContentOne = results.get(fileOne);
|
315 | var modifiedContentTwo = results.get(fileTwo);
|
316 | var modifiedContentThree = results.get(fileThree);
|
317 | var modifiedContentFour = results.get(fileFour);
|
318 | var modifiedContentFive = results.get(fileFive);
|
319 | var modifiedContentSix = results.get(fileSix);
|
320 | var modifiedContentSeven = results.get(fileSeven);
|
321 | var nonExistentVars = [
|
322 | GeneratorConstants.CLASSNAME_VARIABLE,
|
323 | GeneratorConstants.FILENAME_VARIABLE,
|
324 | GeneratorConstants.SUPPLIEDNAME_VARIABLE,
|
325 | GeneratorConstants.TAB_CONTENT_VARIABLE,
|
326 | GeneratorConstants.TAB_VARIABLES_VARIABLE
|
327 | ];
|
328 | for (var _i = 0, nonExistentVars_1 = nonExistentVars; _i < nonExistentVars_1.length; _i++) {
|
329 | var v = nonExistentVars_1[_i];
|
330 | expect(modifiedContentOne.indexOf(v)).toEqual(-1);
|
331 | expect(modifiedContentTwo.indexOf(v)).toEqual(-1);
|
332 | expect(modifiedContentThree.indexOf(v)).toEqual(-1);
|
333 | expect(modifiedContentFour.indexOf(v)).toEqual(-1);
|
334 | expect(modifiedContentFive.indexOf(v)).toEqual(-1);
|
335 | expect(modifiedContentSix.indexOf(v)).toEqual(-1);
|
336 | expect(modifiedContentSeven.indexOf(v)).toEqual(-1);
|
337 | }
|
338 | });
|
339 | });
|
340 | describe('writeGeneratedFiles', function () {
|
341 | it('should return the list of files generated', function () {
|
342 | var map = new Map();
|
343 | var templateDir = '/Users/noone/project/node_modules/ionic-angular/templates/component';
|
344 | var fileContent = 'SomeContent';
|
345 | var knownValues = [
|
346 | 'html.tmpl',
|
347 | 'scss.tmpl',
|
348 | 'spec.ts.tmpl',
|
349 | 'ts.tmpl',
|
350 | 'module.tmpl'
|
351 | ];
|
352 | var fileName = 'settings-view';
|
353 | var dirToWrite = path_1.join('/Users/noone/project/src/components', fileName);
|
354 | map.set(path_1.join(templateDir, knownValues[0]), fileContent);
|
355 | map.set(path_1.join(templateDir, knownValues[1]), fileContent);
|
356 | map.set(path_1.join(templateDir, knownValues[2]), fileContent);
|
357 | map.set(path_1.join(templateDir, knownValues[3]), fileContent);
|
358 | map.set(path_1.join(templateDir, knownValues[4]), fileContent);
|
359 | spyOn(helpers, helpers.mkDirpAsync.name).and.returnValue(Promise.resolve());
|
360 | spyOn(helpers, helpers.writeFileAsync.name).and.returnValue(Promise.resolve());
|
361 | var promise = util.writeGeneratedFiles({ dirToWrite: dirToWrite, fileName: fileName }, map);
|
362 | return promise.then(function (filesCreated) {
|
363 | var fileExtensions = knownValues.map(function (knownValue) {
|
364 | return path_1.basename(knownValue, GeneratorConstants.KNOWN_FILE_EXTENSION);
|
365 | });
|
366 | expect(filesCreated[0]).toEqual(path_1.join(dirToWrite, fileName + "." + fileExtensions[0]));
|
367 | expect(filesCreated[1]).toEqual(path_1.join(dirToWrite, fileName + "." + fileExtensions[1]));
|
368 | expect(filesCreated[2]).toEqual(path_1.join(dirToWrite, fileName + "." + fileExtensions[2]));
|
369 | expect(filesCreated[3]).toEqual(path_1.join(dirToWrite, fileName + "." + fileExtensions[3]));
|
370 | expect(filesCreated[4]).toEqual(path_1.join(dirToWrite, fileName + "." + fileExtensions[4]));
|
371 | });
|
372 | });
|
373 | });
|
374 | describe('getDirToWriteToByType', function () {
|
375 | var context;
|
376 | var componentsDir = '/path/to/components';
|
377 | var directivesDir = '/path/to/directives';
|
378 | var pagesDir = '/path/to/pages';
|
379 | var pipesDir = '/path/to/pipes';
|
380 | var providersDir = '/path/to/providers';
|
381 | beforeEach(function () {
|
382 | context = {
|
383 | componentsDir: componentsDir,
|
384 | directivesDir: directivesDir,
|
385 | pagesDir: pagesDir,
|
386 | pipesDir: pipesDir,
|
387 | providersDir: providersDir
|
388 | };
|
389 | });
|
390 | it('should return the appropriate components directory', function () {
|
391 | expect(util.getDirToWriteToByType(context, 'component')).toEqual(componentsDir);
|
392 | });
|
393 | it('should return the appropriate directives directory', function () {
|
394 | expect(util.getDirToWriteToByType(context, 'directive')).toEqual(directivesDir);
|
395 | });
|
396 | it('should return the appropriate pages directory', function () {
|
397 | expect(util.getDirToWriteToByType(context, 'page')).toEqual(pagesDir);
|
398 | });
|
399 | it('should return the appropriate pipes directory', function () {
|
400 | expect(util.getDirToWriteToByType(context, 'pipe')).toEqual(pipesDir);
|
401 | });
|
402 | it('should return the appropriate providers directory', function () {
|
403 | expect(util.getDirToWriteToByType(context, 'provider')).toEqual(providersDir);
|
404 | });
|
405 | it('should throw error upon unknown generator type', function () {
|
406 | expect(function () { return util.getDirToWriteToByType(context, 'dan'); }).toThrowError('Unknown Generator Type: dan');
|
407 | });
|
408 | });
|
409 | describe('getNgModules', function () {
|
410 | var context;
|
411 | var componentsDir = path_1.join(process.cwd(), 'path', 'to', 'components');
|
412 | var directivesDir = path_1.join(process.cwd(), 'path', 'to', 'directives');
|
413 | var pagesDir = path_1.join(process.cwd(), 'path', 'to', 'pages');
|
414 | var pipesDir = path_1.join(process.cwd(), 'path', 'to', 'pipes');
|
415 | var providersDir = path_1.join(process.cwd(), 'path', 'to', 'providers');
|
416 | beforeEach(function () {
|
417 | context = {
|
418 | componentsDir: componentsDir,
|
419 | directivesDir: directivesDir,
|
420 | pagesDir: pagesDir,
|
421 | pipesDir: pipesDir,
|
422 | providersDir: providersDir
|
423 | };
|
424 | });
|
425 | it('should return an empty list of glob results', function () {
|
426 | var globAllSpy = spyOn(globUtils, globUtils.globAll.name);
|
427 | util.getNgModules(context, []);
|
428 | expect(globAllSpy).toHaveBeenCalledWith([]);
|
429 | });
|
430 | it('should return a list of glob results for components', function () {
|
431 | var globAllSpy = spyOn(globUtils, globUtils.globAll.name);
|
432 | spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue('.module.ts');
|
433 | util.getNgModules(context, ['component']);
|
434 | expect(globAllSpy).toHaveBeenCalledWith([
|
435 | path_1.join(componentsDir, '**', '*.module.ts')
|
436 | ]);
|
437 | });
|
438 | it('should return a list of glob results for pages and components', function () {
|
439 | var globAllSpy = spyOn(globUtils, globUtils.globAll.name);
|
440 | spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue('.module.ts');
|
441 | util.getNgModules(context, ['page', 'component']);
|
442 | expect(globAllSpy).toHaveBeenCalledWith([
|
443 | path_1.join(pagesDir, '**', '*.module.ts'),
|
444 | path_1.join(componentsDir, '**', '*.module.ts')
|
445 | ]);
|
446 | });
|
447 | });
|
448 | });
|