mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
fix gentests.js warnings
This commit is contained in:
parent
73b6d5ff95
commit
ce0232fa1e
20
gentests.js
20
gentests.js
@ -1,6 +1,5 @@
|
||||
const fs = require('fs')
|
||||
const async = require('async')
|
||||
const path = require('path')
|
||||
const promisify = require('pify')
|
||||
|
||||
// start(/\.selectors.js/, generateSelectorTest).catch(console.error)
|
||||
@ -8,7 +7,6 @@ const promisify = require('pify')
|
||||
startContainer(/\.container.js/, generateContainerTest).catch(console.error)
|
||||
|
||||
async function getAllFileNames (dirName) {
|
||||
const rootPath = path.join(__dirname, dirName)
|
||||
const allNames = (await promisify(fs.readdir)(dirName))
|
||||
const fileNames = allNames.filter(name => name.match(/^.+\./))
|
||||
const dirNames = allNames.filter(name => name.match(/^[^.]+$/))
|
||||
@ -16,7 +14,7 @@ async function getAllFileNames (dirName) {
|
||||
const fullPathDirNames = dirNames.map(d => `${dirName}/${d}`)
|
||||
const subNameArrays = await promisify(async.map)(fullPathDirNames, getAllFileNames)
|
||||
let subNames = []
|
||||
subNameArrays.forEach(subNameArray => subNames = [...subNames, ...subNameArray])
|
||||
subNameArrays.forEach(subNameArray => { subNames = [...subNames, ...subNameArray] })
|
||||
|
||||
return [
|
||||
...fileNames.map(name => dirName + '/' + name),
|
||||
@ -24,6 +22,7 @@ async function getAllFileNames (dirName) {
|
||||
]
|
||||
}
|
||||
|
||||
/*
|
||||
async function start (fileRegEx, testGenerator) {
|
||||
const fileNames = await getAllFileNames('./ui/app')
|
||||
const sFiles = fileNames.filter(name => name.match(fileRegEx))
|
||||
@ -46,12 +45,12 @@ async function start (fileRegEx, testGenerator) {
|
||||
})
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
async function startContainer (fileRegEx, testGenerator) {
|
||||
const fileNames = await getAllFileNames('./ui/app')
|
||||
const sFiles = fileNames.filter(name => name.match(fileRegEx))
|
||||
|
||||
let sFileMethodNames
|
||||
async.each(sFiles, async (sFile, cb) => {
|
||||
console.log(`sFile`, sFile)
|
||||
const [, sRootPath, sPath] = sFile.match(/^(.+\/)([^/]+)$/)
|
||||
@ -62,6 +61,9 @@ async function startContainer (fileRegEx, testGenerator) {
|
||||
__dirname + '/' + sFile,
|
||||
'utf8',
|
||||
async (err, result) => {
|
||||
if (err) {
|
||||
console.log('Error: ', err)
|
||||
} else {
|
||||
console.log(`result`, result.length)
|
||||
const returnObjectStrings = result
|
||||
.match(/return\s(\{[\s\S]+?})\n}/g)
|
||||
@ -121,13 +123,14 @@ async function startContainer (fileRegEx, testGenerator) {
|
||||
'utf8'
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}, (err) => {
|
||||
console.log('123', err)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
function generateMethodList (methodArray) {
|
||||
return methodArray.map(n => ' ' + n).join(',\n') + ','
|
||||
}
|
||||
@ -143,7 +146,7 @@ function generateMethodDescribeBlock (methodName, index) {
|
||||
})`
|
||||
return describeBlock
|
||||
}
|
||||
|
||||
*/
|
||||
function generateDispatchMethodDescribeBlock (methodName, index) {
|
||||
const describeBlock =
|
||||
`${index ? ' ' : ''}describe('${methodName}()', () => {
|
||||
@ -154,12 +157,13 @@ function generateDispatchMethodDescribeBlock (methodName, index) {
|
||||
})`
|
||||
return describeBlock
|
||||
}
|
||||
|
||||
/*
|
||||
function generateMethodDescribeBlocks (methodArray) {
|
||||
return methodArray
|
||||
.map((methodName, index) => generateMethodDescribeBlock(methodName, index))
|
||||
.join('\n\n')
|
||||
}
|
||||
*/
|
||||
|
||||
function generateDispatchMethodDescribeBlocks (methodArray) {
|
||||
return methodArray
|
||||
@ -167,6 +171,7 @@ function generateDispatchMethodDescribeBlocks (methodArray) {
|
||||
.join('\n\n')
|
||||
}
|
||||
|
||||
/*
|
||||
function generateSelectorTest (name, methodArray) {
|
||||
return `import assert from 'assert'
|
||||
import {
|
||||
@ -192,6 +197,7 @@ describe('${name.match(/^[^.]+/)} utils', () => {
|
||||
|
||||
})`
|
||||
}
|
||||
*/
|
||||
|
||||
function generateContainerTest (sPath, {
|
||||
mapStateToPropsAssertionObject,
|
||||
|
Loading…
x
Reference in New Issue
Block a user