1
- describe ( "Main node files" , function ( ) {
1
+ describe ( "Main node files" , function ( ) {
2
2
const getMainNodeFiles = require ( '../' ) ;
3
3
4
4
it ( 'should not throw with missed dependencies section' , ( ) => {
@@ -63,7 +63,7 @@ describe("Main node files", function() {
63
63
expect ( files ) . toEqual ( [
64
64
'./spec/test_node_modules/test-module-2/main.js' ,
65
65
'./spec/test_node_modules/test-module-2/index.js'
66
- ] ) ;
66
+ ] ) ;
67
67
} ) ;
68
68
69
69
it ( 'should return ordered array if order option specified' , ( ) => {
@@ -80,7 +80,7 @@ describe("Main node files", function() {
80
80
expect ( files ) . toEqual ( [
81
81
'./spec/test_node_modules/test-module-4/index.js' ,
82
82
'./spec/test_node_modules/test-module-3/index.js'
83
- ] ) ;
83
+ ] ) ;
84
84
} ) ;
85
85
86
86
it ( 'should return alphabetically ordered array for the same specified order option values' , ( ) => {
@@ -97,8 +97,8 @@ describe("Main node files", function() {
97
97
expect ( files ) . toEqual ( [
98
98
'./spec/test_node_modules/test-module-3/index.js' ,
99
99
'./spec/test_node_modules/test-module-4/index.js'
100
- ] ) ;
101
- } ) ;
100
+ ] ) ;
101
+ } ) ;
102
102
103
103
it ( 'should return ordered array with packages without specified order' , ( ) => {
104
104
const options = {
@@ -111,7 +111,7 @@ describe("Main node files", function() {
111
111
const files = getMainNodeFiles ( options ) ;
112
112
113
113
expect ( files . length ) . toEqual ( 2 ) ;
114
- } ) ;
114
+ } ) ;
115
115
116
116
it ( 'should return ordered array with packages without specified order at the end' , ( ) => {
117
117
const options = {
@@ -125,7 +125,7 @@ describe("Main node files", function() {
125
125
126
126
expect ( files [ 0 ] ) . toEqual ( './spec/test_node_modules/test-module-4/index.js' ) ;
127
127
expect ( files [ 1 ] ) . toEqual ( './spec/test_node_modules/test-module-3/index.js' ) ;
128
- } ) ;
128
+ } ) ;
129
129
130
130
it ( 'should not return packages that specified in order option but are really absent' , ( ) => {
131
131
const options = {
@@ -138,7 +138,7 @@ describe("Main node files", function() {
138
138
const files = getMainNodeFiles ( options ) ;
139
139
140
140
expect ( files ) . not . toContain ( './spec/test_node_modules/test-module-5/index.js' ) ;
141
- } ) ;
141
+ } ) ;
142
142
143
143
it ( 'should support both overrides and order' , ( ) => {
144
144
const options = {
@@ -158,8 +158,8 @@ describe("Main node files", function() {
158
158
expect ( files ) . toEqual ( [
159
159
'./spec/test_node_modules/test-module-4/main-4.js' ,
160
160
'./spec/test_node_modules/test-module-3/main-3.js'
161
- ] ) ;
162
- } ) ;
161
+ ] ) ;
162
+ } ) ;
163
163
164
164
it ( 'should support both overrides with array and order' , ( ) => {
165
165
const options = {
@@ -179,23 +179,80 @@ describe("Main node files", function() {
179
179
'./spec/test_node_modules/test-module-4/main.js' ,
180
180
'./spec/test_node_modules/test-module-4/index.js' ,
181
181
'./spec/test_node_modules/test-module-3/index.js'
182
- ] ) ;
183
- } ) ;
182
+ ] ) ;
183
+ } ) ;
184
184
185
- it ( 'should not changed order of packages specified in package.json if order option is empty' , ( ) => {
186
- let options = {
185
+ it ( 'should not changed order of packages specified in package.json if order option is empty' , ( ) => {
186
+ const options = {
187
187
packageJsonPath : './spec/standard-reversed.package.json' ,
188
188
nodeModulesPath : './spec/test_node_modules' ,
189
- order : { }
189
+ order : { }
190
190
} ;
191
- let files = getMainNodeFiles ( options ) ;
192
-
193
- console . log ( 'Main files' , files ) ;
191
+ const files = getMainNodeFiles ( options ) ;
194
192
195
193
expect ( files ) . toEqual ( [
196
194
'./spec/test_node_modules/test-module-4/index.js' ,
197
195
'./spec/test_node_modules/test-module-3/index.js'
198
- ] ) ;
199
- } ) ;
196
+ ] ) ;
197
+ } ) ;
198
+
199
+ it ( 'should support scoped packages' , ( ) => {
200
+ const options = {
201
+ packageJsonPath : './spec/scoped.package.json' ,
202
+ nodeModulesPath : './spec/test_node_modules'
203
+ } ;
204
+ const files = getMainNodeFiles ( options ) ;
205
+
206
+ expect ( files ) . toEqual ( [
207
+ './spec/test_node_modules/@scoped/module-1/index.js'
208
+ ] ) ;
209
+ } ) ;
210
+
211
+ it ( 'should support overrides for scoped packages' , ( ) => {
212
+ const options = {
213
+ packageJsonPath : './spec/scoped.package.json' ,
214
+ nodeModulesPath : './spec/test_node_modules' ,
215
+ overrides : {
216
+ '@scoped/module-1' : 'main.js'
217
+ } ,
218
+ } ;
219
+ const files = getMainNodeFiles ( options ) ;
220
+
221
+ expect ( files ) . toEqual ( [
222
+ './spec/test_node_modules/@scoped/module-1/main.js'
223
+ ] ) ;
224
+ } ) ;
225
+
226
+ it ( 'should support array overrides for scoped packages' , ( ) => {
227
+ const options = {
228
+ packageJsonPath : './spec/scoped.package.json' ,
229
+ nodeModulesPath : './spec/test_node_modules' ,
230
+ overrides : {
231
+ '@scoped/module-1' : [ 'main.js' , 'index.js' ]
232
+ } ,
233
+ } ;
234
+ const files = getMainNodeFiles ( options ) ;
235
+
236
+ expect ( files ) . toEqual ( [
237
+ './spec/test_node_modules/@scoped/module-1/main.js' ,
238
+ './spec/test_node_modules/@scoped/module-1/index.js' ,
239
+ ] ) ;
240
+ } ) ;
241
+
242
+ it ( 'should support relative paths in overrides for scoped packages' , ( ) => {
243
+ const options = {
244
+ packageJsonPath : './spec/scoped.package.json' ,
245
+ nodeModulesPath : './spec/test_node_modules' ,
246
+ overrides : {
247
+ '@scoped/module-1' : [ '../module-2/index.js' , 'index.js' ]
248
+ } ,
249
+ } ;
250
+ const files = getMainNodeFiles ( options ) ;
251
+
252
+ expect ( files ) . toEqual ( [
253
+ './spec/test_node_modules/@scoped/module-2/index.js' ,
254
+ './spec/test_node_modules/@scoped/module-1/index.js'
255
+ ] ) ;
256
+ } ) ;
200
257
201
258
} ) ;
0 commit comments