@@ -4,6 +4,8 @@ var expect = require('chai').expect;
4
4
var path = require ( 'path' ) ;
5
5
var dynamicPathParser = require ( '../../addon/ng2/utilities/dynamic-path-parser' ) ;
6
6
7
+ var appDir = `${ path . sep } src${ path . sep } client${ path . sep } app` ;
8
+
7
9
describe ( 'dynamic path parser' , ( ) => {
8
10
var project ;
9
11
var entityName = 'temp-name' ;
@@ -14,50 +16,50 @@ describe('dynamic path parser', () => {
14
16
it ( 'parse from proj root dir' , ( ) => {
15
17
process . env . PWD = process . cwd ( ) ;
16
18
var result = dynamicPathParser ( project , entityName ) ;
17
- expect ( result . dir ) . to . equal ( '' ) ;
19
+ expect ( result . dir ) . to . equal ( appDir ) ;
18
20
expect ( result . name ) . to . equal ( entityName ) ;
19
21
} ) ;
20
22
21
23
it ( 'parse from proj src dir' , ( ) => {
22
24
process . env . PWD = path . join ( process . cwd ( ) , 'src' ) ;
23
25
var result = dynamicPathParser ( project , entityName ) ;
24
- expect ( result . dir ) . to . equal ( '' ) ;
26
+ expect ( result . dir ) . to . equal ( appDir ) ;
25
27
expect ( result . name ) . to . equal ( entityName ) ;
26
28
} ) ;
27
29
28
30
it ( `parse from proj src${ path . sep } client dir` , ( ) => {
29
31
process . env . PWD = path . join ( process . cwd ( ) , 'src' , 'client' ) ;
30
32
var result = dynamicPathParser ( project , entityName ) ;
31
- expect ( result . dir ) . to . equal ( '' ) ;
33
+ expect ( result . dir ) . to . equal ( appDir ) ;
32
34
expect ( result . name ) . to . equal ( entityName ) ;
33
35
} ) ;
34
36
35
37
it ( `parse from proj src${ path . sep } client${ path . sep } app dir` , ( ) => {
36
38
process . env . PWD = path . join ( process . cwd ( ) , 'src' , 'client' , 'app' ) ;
37
39
var result = dynamicPathParser ( project , entityName ) ;
38
- expect ( result . dir ) . to . equal ( '' ) ;
40
+ expect ( result . dir ) . to . equal ( appDir ) ;
39
41
expect ( result . name ) . to . equal ( entityName ) ;
40
42
} ) ;
41
43
42
44
it ( `parse from proj src${ path . sep } client${ path . sep } app${ path . sep } child-dir` , ( ) => {
43
45
process . env . PWD = path . join ( process . cwd ( ) , 'src' , 'client' , 'app' , 'child-dir' ) ;
44
46
var result = dynamicPathParser ( project , entityName ) ;
45
- expect ( result . dir ) . to . equal ( `${ path . sep } child-dir` ) ;
47
+ expect ( result . dir ) . to . equal ( `${ appDir } ${ path . sep } child-dir` ) ;
46
48
expect ( result . name ) . to . equal ( entityName ) ;
47
49
} ) ;
48
50
49
51
it ( `parse from proj src${ path . sep } client${ path . sep } app${ path . sep } child-dir w/ ..${ path . sep } ` , ( ) => {
50
52
process . env . PWD = path . join ( process . cwd ( ) , 'src' , 'client' , 'app' , 'child-dir' ) ;
51
53
var result = dynamicPathParser ( project , '..' + path . sep + entityName ) ;
52
- expect ( result . dir ) . to . equal ( '' ) ;
54
+ expect ( result . dir ) . to . equal ( appDir ) ;
53
55
expect ( result . name ) . to . equal ( entityName ) ;
54
56
} ) ;
55
57
56
58
it ( `parse from proj src${ path . sep } client${ path . sep } app${ path . sep } child-dir${ path . sep } grand-child-dir w/ ..${ path . sep } ` ,
57
59
( ) => {
58
60
process . env . PWD = path . join ( process . cwd ( ) , 'src' , 'client' , 'app' , 'child-dir' , 'grand-child-dir' ) ;
59
61
var result = dynamicPathParser ( project , '..' + path . sep + entityName ) ;
60
- expect ( result . dir ) . to . equal ( `${ path . sep } child-dir` ) ;
62
+ expect ( result . dir ) . to . equal ( `${ appDir } ${ path . sep } child-dir` ) ;
61
63
expect ( result . name ) . to . equal ( entityName ) ;
62
64
} ) ;
63
65
} ) ;
0 commit comments