Browse Source

move tests to __tests__ folder; enable tests

mightyplow 7 years ago
parent
commit
d9519f094c

+ 5 - 8
package.json

@@ -6,16 +6,17 @@
   "private": true,
   "devDependencies": {
     "babel-cli": "^6.26.0",
-    "babel-preset-es2015": "^6.22.0",
+    "babel-preset-env": "^1.6.0",
+    "babel-preset-stage-2": "^6.24.1"
     "nodeunit": "^0.10.2",
     "rimraf": "^2.6.1"
   },
   "scripts": {
     "createPackageJson": "node bin/createPackageJson.js",
     "nodeunit": "nodeunit",
-    "test": "nodeunit tests",
-    "build": "rimraf dist && babel src -d dist",
-    "prepublish": "npm run build && npm run createPackageJson",
+    "test": "babel-node node_modules/.bin/nodeunit src/**/__tests__/*.test.js",
+    "build": "rimraf dist && babel src -d dist --ignore __tests__",
+    "prepublish": "npm run test && npm run build && npm run createPackageJson",
     "publish": "cd dist && npm publish"
   },
   "keywords": [
@@ -35,9 +36,5 @@
       "env",
       "stage-2"
     ]
-  },
-  "dependencies": {
-    "babel-preset-env": "^1.6.0",
-    "babel-preset-stage-2": "^6.24.1"
   }
 }

+ 11 - 0
src/array/__tests__/toArray.test.js

@@ -0,0 +1,11 @@
+import toArray from '../toArray';
+
+export default test => {
+    test.ok(typeof toArray === 'function', 'toArray should be a function');
+    test.ok(Array.isArray(toArray()), 'should return an array');
+
+    test.ok(!Array.isArray(arguments), 'arguments should not be an array');
+    test.ok(Array.isArray(toArray(arguments)), 'arguments should not be an array');
+
+    test.done();
+};

+ 13 - 0
src/function/__tests__/combine.test.js

@@ -0,0 +1,13 @@
+export default test => {
+    const combine = require('../index').combine;
+
+    test.ok(typeof combine === 'function', 'combine should be a function');
+
+    const a = val => val * 10;
+    const b = val => val * 10;
+
+    const fn = combine(a, b);
+    test.ok(fn(3) === 300, 'combine should return result of all applied functions');
+
+    test.done();
+};

+ 6 - 0
src/object/__tests__/filter.test.js

@@ -0,0 +1,6 @@
+export default test => {
+    const filter = require('../index').filter;
+
+    test.ok(typeof filter === 'function', 'filter should be a function');
+    test.done();
+};

+ 0 - 14
tests/array.js

@@ -1,14 +0,0 @@
-'use strict'
-
-module.exports = {
-    toArray: test => {
-        const toArray = require('../src/array/toArray').toArray;
-
-        test.ok(typeof toArray === 'function', 'toArray should be a function');
-        test.ok(Array.isArray(toArray()), 'should return an array');
-        test.ok(!Array.isArray(arguments), 'arguments should not be an array');
-        test.ok(Array.isArray(toArray(arguments)), 'arguments should not be an array');
-
-        test.done();
-    }
-};

+ 0 - 17
tests/function.js

@@ -1,17 +0,0 @@
-'use strict';
-
-module.exports = {
-    combine: test => {
-        const combine = require('../src/function').combine;
-
-        test.ok(typeof combine === 'function', 'combine should be a function');
-
-        const a = val => val * 10;
-        const b = val => val * 10;
-
-        const fn = combine(a, b);
-        test.ok(fn(3) === 300, 'combine should return result of all applied functions');
-
-        test.done();
-    }
-};

+ 0 - 10
tests/object.js

@@ -1,10 +0,0 @@
-'use strict'
-
-module.exports = {
-    filter: test => {
-        const filter = require('../src/object').filter;
-
-        test.ok(typeof filter === 'function', 'filter should be a function');
-        test.done();
-    }
-};