Created
January 17, 2020 23:30
-
-
Save JavierGelatti/29c378b2a2beb6222ed0c734d20db957 to your computer and use it in GitHub Desktop.
Codemod madness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (fileInfo, api) => { | |
const j = api.jscodeshift; | |
return j(fileInfo.source) | |
.find(j.CallExpression, { | |
callee: { | |
type: 'MemberExpression', | |
object: { | |
type: 'Identifier', | |
name: 'assert', | |
}, | |
property: { name: 'that' }, | |
}, | |
} | |
) | |
.replaceWith(cosa => j.callExpression(j.identifier('expect'), cosa.value.arguments)) | |
.toSource(); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (fileInfo, api) => { | |
const j = api.jscodeshift; | |
return j(fileInfo.source) | |
.find(j.CallExpression, { | |
callee: { | |
type: 'MemberExpression', | |
object: { | |
type: 'Identifier', | |
name: 'assert', | |
}, | |
property: { name: 'isTrue' }, | |
}, | |
} | |
) | |
.replaceWith(cosa => | |
j.callExpression( | |
{ | |
type: 'MemberExpression', | |
object: j.callExpression(j.identifier('expect'), cosa.value.arguments), | |
property: 'toEqual' | |
}, | |
[ j.identifier('true') ] | |
) | |
) | |
.toSource(); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (fileInfo, api) => { | |
const j = api.jscodeshift; | |
return j(fileInfo.source) | |
.find(j.Identifier, { name: 'suite' }) | |
.replaceWith(cosa => { | |
cosa.value.name = "describe" | |
return cosa.value | |
}) | |
.toSource(); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (fileInfo, api) => { | |
const j = api.jscodeshift; | |
return j(fileInfo.source) | |
.find(j.CallExpression, { | |
callee: { | |
type: 'MemberExpression', | |
property: { name: 'isEqualTo' }, | |
}, | |
} | |
) | |
.replaceWith(cosa => { | |
cosa.value.callee.property.name = "toEqual" | |
return cosa.value | |
}) | |
.toSource(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment