diff options
| author | Shinigami <[email protected]> | 2022-01-21 22:29:24 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-01-21 22:29:24 +0100 |
| commit | 60c90028ba76b7e291fdb8152425b93c41b117c9 (patch) | |
| tree | cfaf146a883f902acc351c7c2cba095c459ec36f /test/support/function-helpers.js | |
| parent | 2da0cec2f91f54f56b509414a8b29b3831d58412 (diff) | |
| download | faker-60c90028ba76b7e291fdb8152425b93c41b117c9.tar.xz faker-60c90028ba76b7e291fdb8152425b93c41b117c9.zip | |
chore(test): migrate to vitest (#235)
Diffstat (limited to 'test/support/function-helpers.js')
| -rw-r--r-- | test/support/function-helpers.js | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/test/support/function-helpers.js b/test/support/function-helpers.js deleted file mode 100644 index f8dfe68e..00000000 --- a/test/support/function-helpers.js +++ /dev/null @@ -1,59 +0,0 @@ -if (typeof module !== 'undefined') { - var assert = require('assert'); - var sinon = require('sinon'); - var faker = require('../../lib').faker; -} - -var functionHelpers = {}; - -module.exports = functionHelpers; - -var IGNORED_MODULES = [ - 'locales', - 'locale', - 'localeFallback', - 'definitions', - 'fake', - 'helpers', - 'mersenne', -]; -var IGNORED_METHODS = { - system: ['directoryPath', 'filePath'], // these are TODOs -}; - -function isTestableModule(mod) { - return IGNORED_MODULES.indexOf(mod) === -1; -} - -function isMethodOf(mod) { - return function (meth) { - return typeof faker[mod][meth] === 'function'; - }; -} - -function isTestableMethod(mod) { - return function (meth) { - return !(mod in IGNORED_METHODS && IGNORED_METHODS[mod].indexOf(meth) >= 0); - }; -} - -function both(pred1, pred2) { - return function (value) { - return pred1(value) && pred2(value); - }; -} - -// Basic smoke tests to make sure each method is at least implemented and returns a value. - -functionHelpers.modulesList = function modulesList() { - var modules = Object.keys(faker) - .filter(isTestableModule) - .reduce(function (result, mod) { - result[mod] = Object.keys(faker[mod]).filter( - both(isMethodOf(mod), isTestableMethod(mod)) - ); - return result; - }, {}); - - return modules; -}; |
