Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit b680eb8

Browse files
committed
chore(tests): test getDirToWriteToByType
1 parent 4e6e372 commit b680eb8

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/generators/util.spec.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,47 @@ export class $CLASSNAMEModule {}
289289
});
290290
});
291291
});
292+
293+
describe('getDirToWriteToByType', () => {
294+
let context: any;
295+
const componentsDir = '/path/to/components';
296+
const directivesDir = '/path/to/directives';
297+
const pagesDir = '/path/to/pages';
298+
const pipesDir = '/path/to/pipes';
299+
const providersDir = '/path/to/providers';
300+
301+
beforeEach(() => {
302+
context = {
303+
componentsDir,
304+
directivesDir,
305+
pagesDir,
306+
pipesDir,
307+
providersDir,
308+
};
309+
});
310+
311+
it('should return the appropriate components directory', () => {
312+
expect(util.getDirToWriteToByType(context, 'component')).toEqual(componentsDir);
313+
});
314+
315+
it('should return the appropriate directives directory', () => {
316+
expect(util.getDirToWriteToByType(context, 'directive')).toEqual(directivesDir);
317+
});
318+
319+
it('should return the appropriate pages directory', () => {
320+
expect(util.getDirToWriteToByType(context, 'page')).toEqual(pagesDir);
321+
});
322+
323+
it('should return the appropriate pipes directory', () => {
324+
expect(util.getDirToWriteToByType(context, 'pipe')).toEqual(pipesDir);
325+
});
326+
327+
it('should return the appropriate providers directory', () => {
328+
expect(util.getDirToWriteToByType(context, 'provider')).toEqual(providersDir);
329+
});
330+
331+
it('should throw error upon unknown generator type', () => {
332+
expect(() => util.getDirToWriteToByType(context, 'dan')).toThrowError('Unknown Generator Type: dan');
333+
});
334+
});
292335
});

0 commit comments

Comments
 (0)