1
1
const { getVueJestConfig, getCustomTransformer } = require ( './utils' )
2
- const vueOptionsNamespace = require ( './constants' ) . vueOptionsNamespace
3
2
4
3
function applyTransformer (
5
4
transformer ,
6
5
blocks ,
7
- vueOptionsNamespace ,
6
+ componentNamespace ,
8
7
filename ,
9
8
config
10
9
) {
11
- return transformer . process ( { blocks, vueOptionsNamespace , filename, config } )
10
+ return transformer . process ( { blocks, componentNamespace , filename, config } )
12
11
}
13
12
14
13
function groupByType ( acc , block ) {
@@ -17,9 +16,9 @@ function groupByType(acc, block) {
17
16
return acc
18
17
}
19
18
20
- module . exports = function ( allBlocks , filename , config ) {
19
+ module . exports = ( allBlocks , filename , componentNamespace , config ) => {
21
20
const blocksByType = allBlocks . reduce ( groupByType , { } )
22
- const code = [ ]
21
+ const codes = [ ]
23
22
for ( const [ type , blocks ] of Object . entries ( blocksByType ) ) {
24
23
const transformer = getCustomTransformer (
25
24
getVueJestConfig ( config ) . transform ,
@@ -29,13 +28,12 @@ module.exports = function(allBlocks, filename, config) {
29
28
const codeStr = applyTransformer (
30
29
transformer ,
31
30
blocks ,
32
- vueOptionsNamespace ,
31
+ componentNamespace ,
33
32
filename ,
34
33
config
35
34
)
36
- code . push ( codeStr )
35
+ codes . push ( codeStr )
37
36
}
38
37
}
39
-
40
- return code . length ? code . join ( '\n' ) : ''
38
+ return codes
41
39
}
0 commit comments