@@ -14,7 +14,8 @@ var twoPartsDir = path.resolve(dir + '/files/two-parts') + path.sep,
14
14
emptyDir = path . resolve ( dir + '/files/empty' ) + path . sep ,
15
15
twoComponentsSameDir = path . resolve ( dir + '/files/two-components-same-dir' ) + path . sep ,
16
16
twoComponentsDuplicateSameDir = path . resolve ( dir + '/files/two-components-duplicate-same-dir' ) + path . sep ,
17
- twoPartsDirCustomScript = path . resolve ( dir + '/files/two-parts-custom-script' ) + path . sep ;
17
+ twoPartsDirCustomScript = path . resolve ( dir + '/files/two-parts-custom-script' ) + path . sep ,
18
+ similarComponentNamesDir = path . resolve ( dir + '/files/similar-component-names' ) + path . sep ;
18
19
19
20
beforeEach ( function ( ) {
20
21
loader = require ( '../index' ) ;
@@ -48,11 +49,11 @@ describe('loader: errors', function () {
48
49
} ) ;
49
50
50
51
it ( 'should throw duplication TypeError - multiple components in same directory' , function ( ) {
51
- var content = require ( duplicateDir + 'Component .vue' ) ;
52
+ var content = require ( twoComponentsDuplicateSameDir + 'SecondComponent .vue' ) ;
52
53
53
54
assert . throws ( function ( ) {
54
- loader . apply ( _ . assign ( { } , webpack , { context : twoComponentsDuplicateSameDir } ) , [ content , { file : 'Component .vue.js' } ] ) ;
55
- } , TypeError , 'File "SecondComponent.vue.html " can\'t be used as "template", because it was already defined in "FirstComponent .vue.html".' ) ;
55
+ loader . apply ( _ . assign ( { } , webpack , { context : twoComponentsDuplicateSameDir } ) , [ content , { file : 'SecondComponent .vue.js' } ] ) ;
56
+ } , TypeError , 'File "SecondComponent.vue.pug " can\'t be used as "template", because it was already defined in "SecondComponent .vue.html".' ) ;
56
57
} ) ;
57
58
} ) ;
58
59
@@ -257,4 +258,26 @@ describe('loader: success', function () {
257
258
258
259
assert . strictEqual ( result , expected ) ;
259
260
} ) ;
261
+
262
+ it ( 'should has two parts even when similar component names occurs - first component' , function ( ) {
263
+ var content = require ( similarComponentNamesDir + 'Component.vue' ) ;
264
+
265
+ var expected = '<template separated src="' + similarComponentNamesDir + 'Component.vue.html" lang="html"></template>' +
266
+ '<script separated src="' + similarComponentNamesDir + 'Component.vue.js" lang="js"></script>' ;
267
+
268
+ var result = loader . apply ( _ . assign ( { } , webpack , { context : similarComponentNamesDir } ) , [ content , { file : 'Component.vue.js' } ] ) ;
269
+
270
+ assert . strictEqual ( result , expected ) ;
271
+ } ) ;
272
+
273
+ it ( 'should has two parts even when similar component names occurs - second component' , function ( ) {
274
+ var content = require ( similarComponentNamesDir + 'SimilarComponent.vue' ) ;
275
+
276
+ var expected = '<template separated src="' + similarComponentNamesDir + 'SimilarComponent.vue.html" lang="html"></template>' +
277
+ '<script separated src="' + similarComponentNamesDir + 'SimilarComponent.vue.js" lang="js"></script>' ;
278
+
279
+ var result = loader . apply ( _ . assign ( { } , webpack , { context : similarComponentNamesDir } ) , [ content , { file : 'SimilarComponent.vue.js' } ] ) ;
280
+
281
+ assert . strictEqual ( result , expected ) ;
282
+ } ) ;
260
283
} ) ;
0 commit comments