lib/utils/factory.js
raw| 1 | "use strict"; |
| 2 | |
| 3 | var isFunction = require("es5-ext/function/is-function") |
| 4 | , oForEach = require("es5-ext/object/for-each"); |
| 5 | |
| 6 | module.exports = function (scopes, tests) { |
| 7 | var result = {}; |
| 8 | oForEach(scopes, function (scope, typeName) { |
| 9 | if (isFunction(tests)) { |
| 10 | result[typeName] = tests.bind(scope); |
| 11 | } else { |
| 12 | oForEach(tests, function (test, testName) { |
| 13 | result[typeName + ": " + testName] = test.bind(scope); |
| 14 | }); |
| 15 | } |
| 16 | }); |
| 17 | |
| 18 | return result; |
| 19 | }; |