@@ -13,160 +13,157 @@ describe('barrel-management', () => {
13
13
var blueprint ;
14
14
var installationDirectory ;
15
15
16
- beforeEach ( ( ) => {
17
- blueprint = new Blueprint ( '/' ) ;
18
- blueprint . project = {
19
- root : '/'
20
- }
21
- } ) ;
16
+ beforeEach ( ( ) => {
17
+ blueprint = new Blueprint ( '/' ) ;
18
+ blueprint . project = {
19
+ root : '/'
20
+ }
21
+ } ) ;
22
22
23
23
describe ( 'when not shared' , ( ) => {
24
24
25
25
26
26
beforeEach ( ( ) => {
27
- var rootName = path . parse ( process . cwd ( ) ) ;
27
+ var mockDrive = {
28
+ '/src/app/my-component' : { }
29
+ } ;
30
+ mockFs ( mockDrive ) ;
28
31
29
- var mockFolder = { } ;
30
- var mockDrive = {
31
- '/src/app/my-component' : { }
32
- } ;
33
- mockFs ( mockFolder ) ;
34
-
35
- installationDirectory = path . join ( 'src' , 'app' , 'my-component' ) ;
32
+ installationDirectory = path . join ( 'src' , 'app' , 'my-component' ) ;
36
33
} ) ;
37
34
38
35
afterEach ( ( ) => {
39
- mockFs . restore ( ) ;
36
+ mockFs . restore ( ) ;
40
37
} ) ;
41
38
42
- it ( 'should do nothing' , ( ) => {
43
- return addBarrelRegistration ( blueprint , installationDirectory ) . then ( ( ) => {
39
+ it ( 'should do nothing' , ( ) => {
40
+ return addBarrelRegistration ( blueprint , installationDirectory ) . then ( ( ) => {
44
41
var barrelPath = path . join ( installationDirectory , 'index.ts' ) ;
45
42
expect ( existsSync ( barrelPath ) ) . to . equal ( false ) ;
46
- } ) ;
47
- } ) ;
43
+ } ) ;
44
+ } ) ;
48
45
} ) ;
49
46
50
47
describe ( 'no pre-existing barrel' , ( ) => {
51
48
52
49
beforeEach ( ( ) => {
53
- var mockDrive = {
54
- '/src/app/shared/my-component' : { }
55
- } ;
56
- mockFs ( mockDrive ) ;
50
+ var mockDrive = {
51
+ '/src/app/shared/my-component' : { }
52
+ } ;
53
+ mockFs ( mockDrive ) ;
57
54
58
- installationDirectory = path . join ( '/src/app/shared/my-component' ) ;
55
+ installationDirectory = path . join ( '/src/app/shared/my-component' ) ;
59
56
} ) ;
60
57
61
58
afterEach ( ( ) => {
62
- mockFs . restore ( ) ;
59
+ mockFs . restore ( ) ;
63
60
} ) ;
64
61
65
- it ( 'create barrel from installation dir' , ( ) => {
66
- return addBarrelRegistration ( blueprint , installationDirectory ) . then ( ( ) => {
67
- var fs = require ( 'fs' ) ;
62
+ it ( 'create barrel from installation dir' , ( ) => {
63
+ return addBarrelRegistration ( blueprint , installationDirectory ) . then ( ( ) => {
64
+ var fs = require ( 'fs' ) ;
68
65
var barrelPath = path . join ( installationDirectory , '..' , 'index.ts' ) ;
69
66
expect ( existsSync ( barrelPath ) ) . to . equal ( true ) ;
70
67
var contents = fs . readFileSync ( barrelPath , 'utf8' ) ;
71
68
var expectedContents = `export * from './my-component';${ EOL } ` ;
72
69
expect ( contents ) . to . equal ( expectedContents ) ;
73
- } ) ;
74
- } ) ;
70
+ } ) ;
71
+ } ) ;
75
72
76
- it ( 'create barrel from installation dir with file name' , ( ) => {
77
- return addBarrelRegistration ( blueprint , installationDirectory , 'my-smaller-component' ) . then ( ( ) => {
78
- var fs = require ( 'fs' ) ;
73
+ it ( 'create barrel from installation dir with file name' , ( ) => {
74
+ return addBarrelRegistration ( blueprint , installationDirectory , 'my-smaller-component' ) . then ( ( ) => {
75
+ var fs = require ( 'fs' ) ;
79
76
var barrelPath = path . join ( installationDirectory , '..' , 'index.ts' ) ;
80
77
expect ( existsSync ( barrelPath ) ) . to . equal ( true ) ;
81
78
var contents = fs . readFileSync ( barrelPath , 'utf8' ) ;
82
79
var expectedContents = `export * from './my-component/my-smaller-component';${ EOL } ` ;
83
80
expect ( contents ) . to . equal ( expectedContents ) ;
84
- } ) ;
85
- } ) ;
81
+ } ) ;
82
+ } ) ;
86
83
87
84
} ) ;
88
85
89
86
describe ( 'pre-existing barrel' , ( ) => {
90
87
91
88
beforeEach ( ( ) => {
92
- var mockDrive = {
93
- '/src/app/shared' : {
94
- 'my-component' : { } ,
95
- 'index.ts' : `export * from './another-component${ EOL } export * from './other-component${ EOL } `
96
- }
97
- } ;
98
- mockFs ( mockDrive ) ;
89
+ var mockDrive = {
90
+ '/src/app/shared' : {
91
+ 'my-component' : { } ,
92
+ 'index.ts' : `export * from './another-component${ EOL } export * from './other-component${ EOL } `
93
+ }
94
+ } ;
95
+ mockFs ( mockDrive ) ;
99
96
100
- installationDirectory = path . join ( '/src/app/shared/my-component' ) ;
97
+ installationDirectory = path . join ( '/src/app/shared/my-component' ) ;
101
98
} ) ;
102
99
103
100
afterEach ( ( ) => {
104
- mockFs . restore ( ) ;
101
+ mockFs . restore ( ) ;
105
102
} ) ;
106
103
107
- it ( 'update barrel from installation dir' , ( ) => {
108
- return addBarrelRegistration ( blueprint , installationDirectory ) . then ( ( ) => {
109
- var fs = require ( 'fs' ) ;
104
+ it ( 'update barrel from installation dir' , ( ) => {
105
+ return addBarrelRegistration ( blueprint , installationDirectory ) . then ( ( ) => {
106
+ var fs = require ( 'fs' ) ;
110
107
var barrelPath = path . join ( installationDirectory , '..' , 'index.ts' ) ;
111
108
expect ( existsSync ( barrelPath ) ) . to . equal ( true ) ;
112
109
var contents = fs . readFileSync ( barrelPath , 'utf8' ) ;
113
110
var expectedContents = `export * from './another-component${ EOL } export * from './my-component';${ EOL } export * from './other-component${ EOL } ` ;
114
111
expect ( contents ) . to . equal ( expectedContents ) ;
115
- } ) ;
116
- } ) ;
112
+ } ) ;
113
+ } ) ;
117
114
118
- it ( 'updateA barrel from installation dir with file name' , ( ) => {
119
- return addBarrelRegistration ( blueprint , installationDirectory , 'my-smaller-component' ) . then ( ( ) => {
120
- var fs = require ( 'fs' ) ;
115
+ it ( 'updateA barrel from installation dir with file name' , ( ) => {
116
+ return addBarrelRegistration ( blueprint , installationDirectory , 'my-smaller-component' ) . then ( ( ) => {
117
+ var fs = require ( 'fs' ) ;
121
118
var barrelPath = path . join ( installationDirectory , '..' , 'index.ts' ) ;
122
119
expect ( existsSync ( barrelPath ) ) . to . equal ( true ) ;
123
120
var contents = fs . readFileSync ( barrelPath , 'utf8' ) ;
124
121
var expectedContents = `export * from './another-component${ EOL } export * from './my-component/my-smaller-component';${ EOL } export * from './other-component${ EOL } ` ;
125
122
expect ( contents ) . to . equal ( expectedContents ) ;
126
- } ) ;
127
- } ) ;
123
+ } ) ;
124
+ } ) ;
128
125
129
126
} ) ;
130
127
131
128
describe ( 'pre-existing barrel with export already defined' , ( ) => {
132
129
133
130
beforeEach ( ( ) => {
134
- var mockDrive = {
135
- '/src/app/shared' : {
136
- 'my-component' : { } ,
137
- 'index.ts' : `export * from './other-component${ EOL } export * from './my-component';${ EOL } export * from './another-component${ EOL } export * from './my-component/my-smaller-component';${ EOL } `
138
- }
139
- } ;
140
- mockFs ( mockDrive ) ;
131
+ var mockDrive = {
132
+ '/src/app/shared' : {
133
+ 'my-component' : { } ,
134
+ 'index.ts' : `export * from './other-component${ EOL } export * from './my-component';${ EOL } export * from './another-component${ EOL } export * from './my-component/my-smaller-component';${ EOL } `
135
+ }
136
+ } ;
137
+ mockFs ( mockDrive ) ;
141
138
142
- installationDirectory = path . join ( '/src/app/shared/my-component' ) ;
139
+ installationDirectory = path . join ( '/src/app/shared/my-component' ) ;
143
140
} ) ;
144
141
145
142
afterEach ( ( ) => {
146
- mockFs . restore ( ) ;
143
+ mockFs . restore ( ) ;
147
144
} ) ;
148
145
149
- it ( 'update barrel from installation dir should add nothing' , ( ) => {
150
- return addBarrelRegistration ( blueprint , installationDirectory ) . then ( ( ) => {
151
- var fs = require ( 'fs' ) ;
146
+ it ( 'update barrel from installation dir should add nothing' , ( ) => {
147
+ return addBarrelRegistration ( blueprint , installationDirectory ) . then ( ( ) => {
148
+ var fs = require ( 'fs' ) ;
152
149
var barrelPath = path . join ( installationDirectory , '..' , 'index.ts' ) ;
153
150
expect ( existsSync ( barrelPath ) ) . to . equal ( true ) ;
154
151
var contents = fs . readFileSync ( barrelPath , 'utf8' ) ;
155
152
var expectedContents = `export * from './another-component${ EOL } export * from './my-component';${ EOL } export * from './my-component/my-smaller-component';${ EOL } export * from './other-component${ EOL } ` ;
156
153
expect ( contents ) . to . equal ( expectedContents ) ;
157
- } ) ;
158
- } ) ;
154
+ } ) ;
155
+ } ) ;
159
156
160
- it ( 'update barrel from installation dir with file name should add nothing' , ( ) => {
161
- return addBarrelRegistration ( blueprint , installationDirectory , 'my-smaller-component' ) . then ( ( ) => {
162
- var fs = require ( 'fs' ) ;
157
+ it ( 'update barrel from installation dir with file name should add nothing' , ( ) => {
158
+ return addBarrelRegistration ( blueprint , installationDirectory , 'my-smaller-component' ) . then ( ( ) => {
159
+ var fs = require ( 'fs' ) ;
163
160
var barrelPath = path . join ( installationDirectory , '..' , 'index.ts' ) ;
164
161
expect ( existsSync ( barrelPath ) ) . to . equal ( true ) ;
165
162
var contents = fs . readFileSync ( barrelPath , 'utf8' ) ;
166
163
var expectedContents = `export * from './another-component${ EOL } export * from './my-component';${ EOL } export * from './my-component/my-smaller-component';${ EOL } export * from './other-component${ EOL } ` ;
167
164
expect ( contents ) . to . equal ( expectedContents ) ;
168
- } ) ;
169
- } ) ;
165
+ } ) ;
166
+ } ) ;
170
167
171
168
} ) ;
172
169
} ) ;
0 commit comments