@@ -13,7 +13,7 @@ const {
13
13
getRelatedFunctions,
14
14
getModuleTypeFromFilePath
15
15
} = require ( "../utils/code" ) ;
16
- const { getRelativePath, getFolderTreeItem, getTestFilePath , checkPathType, isPathInside} = require ( "../utils/files" ) ;
16
+ const { getRelativePath, getFolderTreeItem, getTestFolderPath , checkPathType, isPathInside} = require ( "../utils/files" ) ;
17
17
const { initScreenForUnitTests} = require ( "./cmdGUI" ) ;
18
18
const { green, red, blue, bold, reset} = require ( '../utils/cmdPrint' ) . colors ;
19
19
@@ -94,23 +94,23 @@ async function reformatDataForPythagoraAPI(funcData, filePath, testFilePath) {
94
94
if ( file . fileName === filePath ) {
95
95
relatedCodeInSameFile = relatedCodeInSameFile . concat ( file . functionNames ) ;
96
96
} else {
97
- let fileName = getRelativePath ( file . fileName , filePath ) ;
97
+ let fileName = getRelativePath ( file . fileName , path . dirname ( filePath ) ) ;
98
98
let code = await stripUnrelatedFunctions ( file . fileName , file . functionNames ) ;
99
99
let fullPath = filePath . substring ( 0 , filePath . lastIndexOf ( '/' ) ) + '/' + fileName ;
100
- code = replaceRequirePaths ( code , filePath , path . resolve ( PYTHAGORA_UNIT_DIR ) + '/brija.test.js' ) ;
100
+ code = replaceRequirePaths ( code , filePath , getTestFolderPath ( filePath , rootPath ) ) ;
101
101
funcData . relatedCode . push ( {
102
102
fileName,
103
103
code,
104
104
functionNames : file . functionNames ,
105
105
exportedAsObject : file . exportedAsObject ,
106
106
syntaxType : file . syntaxType ,
107
- pathRelativeToTest : getRelativePath ( fullPath , testFilePath + '/brija.test.js' )
107
+ pathRelativeToTest : getRelativePath ( fullPath , testFilePath )
108
108
} ) ;
109
109
}
110
110
}
111
111
funcData . functionCode = await stripUnrelatedFunctions ( filePath , relatedCodeInSameFile ) ;
112
- funcData . functionCode = replaceRequirePaths ( funcData . functionCode , path . dirname ( filePath ) , path . resolve ( PYTHAGORA_UNIT_DIR ) + '/brija.test.js' ) ;
113
- funcData . pathRelativeToTest = getRelativePath ( filePath , testFilePath + '/brija.test.js' ) ;
112
+ funcData . functionCode = replaceRequirePaths ( funcData . functionCode , path . dirname ( filePath ) , getTestFolderPath ( filePath , rootPath ) ) ;
113
+ funcData . pathRelativeToTest = getRelativePath ( filePath , testFilePath ) ;
114
114
return funcData ;
115
115
}
116
116
@@ -155,14 +155,14 @@ async function createTests(filePath, prefix, funcToTest) {
155
155
) ;
156
156
spinner . start ( folderStructureTree , indexToPush ) ;
157
157
158
- let testFilePath = path . join ( getTestFilePath ( filePath , rootPath ) , `/${ funcData . functionName } .test.js` ) ;
158
+ let testFilePath = path . join ( getTestFolderPath ( filePath , rootPath ) , `/${ funcData . functionName } .test.js` ) ;
159
159
if ( fs . existsSync ( testFilePath ) ) {
160
160
await spinner . stop ( ) ;
161
161
folderStructureTree [ indexToPush ] . line = `${ green } ${ folderStructureTree [ indexToPush ] . line } ${ reset } ` ;
162
162
continue ;
163
163
}
164
164
165
- let formattedData = await reformatDataForPythagoraAPI ( funcData , filePath , getTestFilePath ( filePath , rootPath ) ) ;
165
+ let formattedData = await reformatDataForPythagoraAPI ( funcData , filePath , getTestFolderPath ( filePath , rootPath ) ) ;
166
166
let { tests, error } = await getUnitTests ( formattedData , ( content ) => {
167
167
scrollableContent . setContent ( content ) ;
168
168
scrollableContent . setScrollPerc ( 100 ) ;
@@ -196,7 +196,7 @@ async function createTests(filePath, prefix, funcToTest) {
196
196
}
197
197
198
198
async function saveTests ( filePath , name , testData ) {
199
- let dir = getTestFilePath ( filePath , rootPath ) ;
199
+ let dir = getTestFolderPath ( filePath , rootPath ) ;
200
200
201
201
if ( ! await checkDirectoryExists ( dir ) ) {
202
202
fs . mkdirSync ( dir , { recursive : true } ) ;
0 commit comments