From a3109fc1020c6f4a8686d032cb7d539a230af258 Mon Sep 17 00:00:00 2001 From: Pedr Browne Date: Sun, 18 Feb 2018 20:53:56 +0100 Subject: [PATCH] refactor(prettier): integrate prettier (#360) Closes #336 --- .eslintrc | 20 ++--- .prettierignore | 0 .prettierrc | 25 ++++++ package.json | 9 +- src/Y.js | 2 +- src/allP.js | 1 - src/appendFlipped.js | 1 - src/cata.js | 1 - src/compact.js | 1 - src/curryRight.js | 3 - src/curryRightN.js | 15 +--- src/defaultWhen.js | 5 +- src/fantasy-land/Identity.js | 11 ++- src/fantasy-land/traits.js | 5 +- src/fantasy-land/util.js | 20 ++++- src/hasPath.js | 1 - src/internal/ap.js | 17 ++-- src/isArray.js | 1 - src/isArrayLike.js | 27 ++++-- src/isAsyncFunction.js | 3 +- src/isEmptyArray.js | 1 - src/isEmptyString.js | 1 - src/isEven.js | 1 - src/isFalsy.js | 1 - src/isGeneratorFunction.js | 12 +-- src/isNegative.js | 1 - src/isNonEmptyString.js | 1 - src/isNotArrayLike.js | 1 - src/isNotAsyncFunction.js | 1 - src/isNotInteger.js | 1 - src/isNotNumber.js | 1 - src/isNotObj.js | 1 - src/isNotObjLike.js | 1 - src/isNotPair.js | 1 - src/isObj.js | 1 - src/isObjLike.js | 1 - src/isOdd.js | 1 - src/isPair.js | 1 - src/isPlainObj.js | 16 ++-- src/isPositive.js | 1 - src/isPromise.js | 1 - src/isThenable.js | 1 - src/isTruthy.js | 1 - src/lensEq.js | 6 +- src/lensIso.js | 15 ++-- src/lensNotEq.js | 2 - src/lensNotSatisfy.js | 2 - src/lensSatisfies.js | 7 +- src/mapIndexed.js | 1 - src/mergePath.js | 4 +- src/neither.js | 1 - src/nonePass.js | 1 - src/notAllPass.js | 1 - src/notBoth.js | 1 - src/omitIndexes.js | 6 +- src/pathNotEq.js | 1 - src/pickIndexes.js | 6 +- src/propNotEq.js | 1 - src/reduceIndexed.js | 1 - src/reduceP.js | 30 ++++--- src/reduceRightP.js | 18 ++-- src/renameKeys.js | 7 +- src/renameKeysWith.js | 4 +- src/viewOr.js | 7 +- src/weave.js | 4 +- src/weaveLazy.js | 5 +- test/Y.js | 11 +-- test/allP.js | 27 +++--- test/appendFlipped.js | 7 +- test/cata.js | 20 +++-- test/compact.js | 17 ++-- test/concatRight.js | 21 ++--- test/curryRight.js | 116 ++++++++++++++---------- test/curryRightN.js | 31 ++++--- test/defaultWhen.js | 9 +- test/fantasy-land/Identity.js | 155 +++++++++++++++++---------------- test/flattenPath.js | 37 ++++---- test/flattenProp.js | 43 +++++---- test/hasPath.js | 17 ++-- test/internal/ap.js | 9 +- test/isArray.js | 5 +- test/isArrayLike.js | 15 ++-- test/isAsyncFunction.js | 5 +- test/isBoolean.js | 5 +- test/isDate.js | 5 +- test/isEmptyArray.js | 5 +- test/isEmptyString.js | 5 +- test/isEven.js | 5 +- test/isFalsy.js | 5 +- test/isFinite.js | 7 +- test/isFloat.js | 9 +- test/isFunction.js | 7 +- test/isGeneratorFunction.js | 5 +- test/isInteger.js | 11 ++- test/isNaN.js | 7 +- test/isNegative.js | 5 +- test/isNilOrEmpty.js | 41 ++++++--- test/isNonEmptyArray.js | 5 +- test/isNonEmptyString.js | 5 +- test/isNotArray.js | 5 +- test/isNotArrayLike.js | 15 ++-- test/isNotAsyncFunction.js | 5 +- test/isNotBoolean.js | 5 +- test/isNotDate.js | 5 +- test/isNotEmpty.js | 35 +++++--- test/isNotFinite.js | 7 +- test/isNotFloat.js | 9 +- test/isNotFunction.js | 7 +- test/isNotGeneratorFunction.js | 5 +- test/isNotInteger.js | 7 +- test/isNotNaN.js | 7 +- test/isNotNil.js | 5 +- test/isNotNull.js | 5 +- test/isNotNumber.js | 5 +- test/isNotObj.js | 9 +- test/isNotObjLike.js | 9 +- test/isNotPair.js | 5 +- test/isNotPlainObj.js | 21 +++-- test/isNotRegExp.js | 7 +- test/isNotString.js | 5 +- test/isNotUndefined.js | 5 +- test/isNotValidDate.js | 9 +- test/isNotValidNumber.js | 5 +- test/isNull.js | 5 +- test/isNumber.js | 5 +- test/isObj.js | 9 +- test/isObjLike.js | 10 +-- test/isOdd.js | 5 +- test/isPair.js | 5 +- test/isPlainObj.js | 22 +++-- test/isPositive.js | 5 +- test/isPromise.js | 27 +++--- test/isRegExp.js | 8 +- test/isString.js | 5 +- test/isThenable.js | 23 +++-- test/isTruthy.js | 5 +- test/isUndefined.js | 5 +- test/isValidDate.js | 5 +- test/isValidNumber.js | 5 +- test/lensEq.js | 7 +- test/lensIso.js | 28 +++--- test/lensNotEq.js | 7 +- test/lensNotSatisfy.js | 34 +++++--- test/lensSatisfies.js | 16 ++-- test/liftF.js | 20 +++-- test/liftFN.js | 51 ++++++++--- test/list.js | 11 ++- test/mapIndexed.js | 50 ++++++----- test/mergePath.js | 15 ++-- test/mergePaths.js | 39 ++++++--- test/mergeProp.js | 15 ++-- test/mergeProps.js | 13 ++- test/mergeRight.js | 20 ++--- test/mocha-bootstrap.js | 2 - test/neither.js | 13 ++- test/nonePass.js | 9 +- test/noop.js | 5 +- test/notAllPass.js | 9 +- test/notBoth.js | 13 ++- test/omitIndexes.js | 38 ++++---- test/pathNotEq.js | 44 +++++----- test/paths.js | 13 ++- test/pickIndexes.js | 39 +++++---- test/propNotEq.js | 37 ++++---- test/reduceIndexed.js | 56 +++++++----- test/reduceP.js | 99 +++++++++++++-------- test/reduceRightP.js | 111 +++++++++++++++-------- test/rejectP.js | 13 ++- test/renameKeys.js | 26 ++++-- test/renameKeysWith.js | 19 ++-- test/resolveP.js | 10 +-- test/seq.js | 34 +++++--- test/shared/Symbol.js | 3 +- test/shared/arguments.js | 4 +- test/shared/eq.js | 1 - test/sliceFrom.js | 13 +-- test/sliceTo.js | 13 +-- test/spreadPath.js | 22 ++--- test/spreadProp.js | 28 +++--- test/stubArray.js | 9 +- test/stubNull.js | 5 +- test/stubObj.js | 9 +- test/stubString.js | 9 +- test/stubUndefined.js | 5 +- test/typescript.js | 5 +- test/viewOr.js | 11 ++- test/weave.js | 22 ++--- test/weaveLazy.js | 22 ++--- tslint.json | 3 +- 189 files changed, 1334 insertions(+), 1142 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc diff --git a/.eslintrc b/.eslintrc index e15e0c4235..d9f89f5181 100644 --- a/.eslintrc +++ b/.eslintrc @@ -10,23 +10,19 @@ } }, "extends": [ - "airbnb-base", - "plugin:ramda/recommended" + "eslint-config-airbnb-base", + "plugin:ramda/recommended", + "prettier" ], - "plugins": ["eslint-plugin-ramda"], + "plugins": ["eslint-plugin-ramda", "prettier"], "rules": { "strict": [2, "global"], "semi": ["error", "always", { "omitLastInOneLineBlock": true}], - "comma-dangle": ["error", { - "arrays": "always-multiline", - "objects": "always-multiline", - "imports": "always-multiline", - "exports": "always-multiline", - "functions": "never" - }], + "space-before-function-paren": "off", + "comma-dangle": ["error", "always-multiline"], "no-underscore-dangle": 0, - "object-curly-newline": 0, - "import/newline-after-import": ["error", { "count": 2 }], + "no-confusing-arrow": "off", + "object-curly-newline": "off", "ramda/always-simplification": ["error"], "ramda/compose-simplification": ["error"], "ramda/eq-by-simplification": ["error"], diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000000..1464f50cf2 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,25 @@ +{ + "printWidth": 80, + "tabWidth": 2, + "semi": true, + "singleQuote": true, + "trailingComma": "es5", + "overrides": [ + { + "files": ".prettierrc", + "options": { "parser": "json" } + }, + { + "files": ".babelrc", + "options": { "parser": "json" } + }, + { + "files": ".eslintrc", + "options": { "parser": "json" } + }, + { + "files": ".nycrc", + "options": { "parser": "json" } + } + ] +} diff --git a/package.json b/package.json index 2f5805a864..401df3cd07 100644 --- a/package.json +++ b/package.json @@ -62,8 +62,7 @@ }, "betterScripts": { "docs": "jsdoc -c jsdoc.json && node ./scripts/jsdoc-inject-dist.js", - "lint": "eslint ./ && tslint -c tslint.json src/index.d.ts", - "lint:fix": "eslint ./ --fix && tslint --fix -c tslint.json src/index.d.ts", + "lint": "prettier test/**.js src/**.js --write && eslint ./ && tslint -c tslint.json src/index.d.ts", "changelog": "conventional-changelog -p angular -i ./CHANGELOG.md -s", "test": "cross-env BABEL_ENV=commonjs mocha", "test:web": "testem ci", @@ -113,9 +112,11 @@ "docdash": "git+https://github.com/char0n/docdash.git#bf4b4eebfdaf042c0ea9038419bc26813f243c94", "es6-promise": "4.2.4", "eslint": "4.17.0", - "eslint-config-airbnb-base": "12.1.0", + "eslint-config-airbnb-base": "=12.1.0", + "eslint-config-prettier": "=2.9.0", "eslint-plugin-import": "2.8.0", "eslint-plugin-mocha": "=4.11.0", + "eslint-plugin-prettier": "=2.6.0", "eslint-plugin-ramda": "=2.4.0", "fantasy-land": "3.5.0", "glob": "=7.1.2", @@ -130,11 +131,13 @@ "nsp": "3.1.0", "nyc": "11.4.1", "phantomjs": "=2.1.7", + "prettier": "=1.10.2", "ramda": "=0.25.0", "rimraf": "=2.6.2", "sinon": "4.3.0", "testem": "2.0.0", "tslint": "=5.9.1", + "tslint-config-prettier": "=1.7.0", "typescript": "2.6.2", "typescript-definition-tester": "=0.0.5", "webpack": "3.11.0" diff --git a/src/Y.js b/src/Y.js index cbc049be19..f45c12463f 100644 --- a/src/Y.js +++ b/src/Y.js @@ -25,6 +25,6 @@ * factorial(5); //=> 120 */ -const Y = le => (f => f(f))(g => le(x => (g(g))(x))); +const Y = le => (f => f(f))(g => le(x => g(g)(x))); export default Y; diff --git a/src/allP.js b/src/allP.js index 86d8ba23a0..9096f2229a 100644 --- a/src/allP.js +++ b/src/allP.js @@ -1,6 +1,5 @@ import { bind } from 'ramda'; - /* eslint-disable max-len */ /** * Composable shortcut for `Promise.all`. diff --git a/src/appendFlipped.js b/src/appendFlipped.js index 2019a1bcfa..aa1216f225 100644 --- a/src/appendFlipped.js +++ b/src/appendFlipped.js @@ -1,6 +1,5 @@ import { append, flip } from 'ramda'; - /** * Returns a new list containing the contents of the given list, followed by the given element. * Like {@link http://ramdajs.com/docs/#append|R.append} but with argument order reversed. diff --git a/src/cata.js b/src/cata.js index caf525400b..2420a40fe7 100644 --- a/src/cata.js +++ b/src/cata.js @@ -2,7 +2,6 @@ import { curry } from 'ramda'; import isFunction from './isFunction'; - /* eslint-disable max-len */ /** * The catamorphism is a way of folding a type into a value. diff --git a/src/compact.js b/src/compact.js index d5043bbe9c..ff12a76cc6 100644 --- a/src/compact.js +++ b/src/compact.js @@ -2,7 +2,6 @@ import { reject } from 'ramda'; import isFalsy from './isFalsy'; - /** * Creates an array with all falsy values removed. * The values false, null, 0, "", undefined, and NaN are falsy. diff --git a/src/curryRight.js b/src/curryRight.js index 7d107f0e25..c74fb0e9b0 100644 --- a/src/curryRight.js +++ b/src/curryRight.js @@ -2,7 +2,6 @@ import { converge, length, identity } from 'ramda'; import curryRightN from './curryRightN'; - /** * Returns a curried equivalent of the provided function. * This function is like curry, except that the provided arguments order is reversed. @@ -24,6 +23,4 @@ import curryRightN from './curryRightN'; */ const curryRight = converge(curryRightN, [length, identity]); - export default curryRight; - diff --git a/src/curryRightN.js b/src/curryRightN.js index 43fa286623..1be7465e2f 100644 --- a/src/curryRightN.js +++ b/src/curryRightN.js @@ -1,6 +1,5 @@ import { curryN, reverse } from 'ramda'; - /** * Returns a curried equivalent of the provided function, with the specified arity. * This function is like curryN, except that the provided arguments order is reversed. @@ -21,16 +20,10 @@ import { curryN, reverse } from 'ramda'; * * concatStringCurried('a')('b')('c'); // => 'cba' */ -const curryRightN = curryN( - 2, - (arity, fn) => - curryN( - arity, - function wrapper(...args) { - return fn.apply(this, reverse(args)); - } - ) +const curryRightN = curryN(2, (arity, fn) => + curryN(arity, function wrapper(...args) { + return fn.apply(this, reverse(args)); + }) ); - export default curryRightN; diff --git a/src/defaultWhen.js b/src/defaultWhen.js index a04381eeb6..2710f796cf 100644 --- a/src/defaultWhen.js +++ b/src/defaultWhen.js @@ -1,6 +1,5 @@ import { curry } from 'ramda'; - /** * Returns the second argument if predicate function returns `true`, * otherwise the third argument is returned. @@ -20,6 +19,8 @@ import { curry } from 'ramda'; * RA.defaultWhen(RA.isNull, 1, null); // => 1 * RA.defaultWhen(RA.isNull, 1, 2); // => 2 */ -const defaultWhen = curry((predicate, defaultVal, val) => (predicate(val) ? defaultVal : val)); +const defaultWhen = curry( + (predicate, defaultVal, val) => (predicate(val) ? defaultVal : val) +); export default defaultWhen; diff --git a/src/fantasy-land/Identity.js b/src/fantasy-land/Identity.js index 19b394b746..1144a64266 100644 --- a/src/fantasy-land/Identity.js +++ b/src/fantasy-land/Identity.js @@ -2,13 +2,18 @@ import { empty as emptyR } from 'ramda'; import { aliases } from './util'; import fl from './mapping'; -import { applyTrait, functorTrait, setoidTrait, semigroupTrait, chainTrait, ordTrait } from './traits'; - +import { + applyTrait, + functorTrait, + setoidTrait, + semigroupTrait, + chainTrait, + ordTrait, +} from './traits'; // we do this here for jsdocs generate properly const { of, ap, map, equals, concat, chain, lte, empty, contramap } = fl; - /** * The simplest {@link https://github.com/fantasyland/fantasy-land|fantasy-land} * compatible monad which attaches no information to values. diff --git a/src/fantasy-land/traits.js b/src/fantasy-land/traits.js index fe098227ca..4f9ca8bc43 100644 --- a/src/fantasy-land/traits.js +++ b/src/fantasy-land/traits.js @@ -4,7 +4,6 @@ import { isString, isNumber, isFunction } from '../index'; import { isSameType } from './util'; import fl from './mapping'; - export const functorTrait = { [fl.map](fn) { return this.constructor[fl.of](fn(this.value)); @@ -49,6 +48,8 @@ export const chainTrait = { export const ordTrait = { [fl.lte](ord) { - return isSameType(this, ord) && (this.value < ord.value || this[fl.equals](ord)); + return ( + isSameType(this, ord) && (this.value < ord.value || this[fl.equals](ord)) + ); }, }; diff --git a/src/fantasy-land/util.js b/src/fantasy-land/util.js index 99dc824f73..68ac36b6b8 100644 --- a/src/fantasy-land/util.js +++ b/src/fantasy-land/util.js @@ -1,14 +1,26 @@ import { - useWith, curry, curryN, toPairs, equals, over, lensIndex, replace, pipe, map, path, - either, complement, + useWith, + curry, + curryN, + toPairs, + equals, + over, + lensIndex, + replace, + pipe, + map, + path, + either, + complement, } from 'ramda'; - // type :: Monad a => a -> String export const type = either(path(['@@type']), path(['constructor', '@@type'])); // typeEquals :: Monad a => String -> a -> Boolean -export const typeEquals = curry((typeIdent, monad) => type(monad) === typeIdent); +export const typeEquals = curry( + (typeIdent, monad) => type(monad) === typeIdent +); // isSameType :: (Monad a, Monad b) => a -> b -> Boolean export const isSameType = curryN(2, useWith(equals, [type, type])); diff --git a/src/hasPath.js b/src/hasPath.js index 5a8d9688fe..95ed58ef57 100644 --- a/src/hasPath.js +++ b/src/hasPath.js @@ -35,5 +35,4 @@ const hasPath = curryN(2, (objPath, obj) => { return hasPath(tail(objPath), path([prop], obj)); // base case }); - export default hasPath; diff --git a/src/internal/ap.js b/src/internal/ap.js index 95766ad3e4..b7df17b63a 100644 --- a/src/internal/ap.js +++ b/src/internal/ap.js @@ -3,17 +3,23 @@ import { ap as apR, curryN, pathSatisfies, both, anyPass } from 'ramda'; import isFunction from '../isFunction'; import fl from '../fantasy-land/mapping'; - -const isFunctor = anyPass([pathSatisfies(isFunction, ['map']), pathSatisfies(isFunction, [fl.map])]); +const isFunctor = anyPass([ + pathSatisfies(isFunction, ['map']), + pathSatisfies(isFunction, [fl.map]), +]); const isApply = both( isFunctor, - anyPass([pathSatisfies(isFunction, ['ap']), pathSatisfies(isFunction, [fl.ap])]) + anyPass([ + pathSatisfies(isFunction, ['ap']), + pathSatisfies(isFunction, [fl.ap]), + ]) ); - const ap = curryN(2, (applyF, applyX) => { // return original ramda `ap` if not Apply spec - if (!isApply(applyF) || !isApply(applyX)) { return apR(applyF, applyX) } + if (!isApply(applyF) || !isApply(applyX)) { + return apR(applyF, applyX); + } try { // new version of `ap` starting from ramda version > 0.23.0 @@ -24,5 +30,4 @@ const ap = curryN(2, (applyF, applyX) => { } }); - export default ap; diff --git a/src/isArray.js b/src/isArray.js index 91f964e85a..1bea0ce1f6 100644 --- a/src/isArray.js +++ b/src/isArray.js @@ -1,6 +1,5 @@ import _isArray from 'ramda/src/internal/_isArray'; - /** * Checks if input value is `Array`. * diff --git a/src/isArrayLike.js b/src/isArrayLike.js index 86e6600873..e135b322fc 100644 --- a/src/isArrayLike.js +++ b/src/isArrayLike.js @@ -3,7 +3,6 @@ import { has } from 'ramda'; import isArray from './isArray'; import isString from './isString'; - /* eslint-disable max-len */ /** * Tests whether or not an object is similar to an array. @@ -28,13 +27,25 @@ import isString from './isString'; * RA.isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true */ /* eslint-enable max-len */ -const isArrayLike = (val) => { - if (isArray(val)) { return true } - if (!val) { return false } - if (isString(val)) { return false } - if (typeof val !== 'object') { return false } - if (val.nodeType === 1) { return !!val.length } - if (val.length === 0) { return true } +const isArrayLike = val => { + if (isArray(val)) { + return true; + } + if (!val) { + return false; + } + if (isString(val)) { + return false; + } + if (typeof val !== 'object') { + return false; + } + if (val.nodeType === 1) { + return !!val.length; + } + if (val.length === 0) { + return true; + } if (val.length > 0) { return has(0, val) && has(val.length - 1, val); } diff --git a/src/isAsyncFunction.js b/src/isAsyncFunction.js index 546736aa1c..75d25cb225 100644 --- a/src/isAsyncFunction.js +++ b/src/isAsyncFunction.js @@ -18,6 +18,7 @@ * RA.isAsyncFunction(() => {}); //=> false */ /* eslint-enable max-len */ -const isAsyncFunction = val => Object.prototype.toString.call(val) === '[object AsyncFunction]'; +const isAsyncFunction = val => + Object.prototype.toString.call(val) === '[object AsyncFunction]'; export default isAsyncFunction; diff --git a/src/isEmptyArray.js b/src/isEmptyArray.js index 3908ae1919..55453c6f72 100644 --- a/src/isEmptyArray.js +++ b/src/isEmptyArray.js @@ -2,7 +2,6 @@ import { both, isEmpty } from 'ramda'; import isArray from './isArray'; - /** * Checks if input value is an empty `Array`. * diff --git a/src/isEmptyString.js b/src/isEmptyString.js index 831f20c391..d8d43ab3bb 100644 --- a/src/isEmptyString.js +++ b/src/isEmptyString.js @@ -1,6 +1,5 @@ import { equals } from 'ramda'; - /** * Checks if input value is an empty `String`. * diff --git a/src/isEven.js b/src/isEven.js index e98d3421a1..a02a3854bc 100644 --- a/src/isEven.js +++ b/src/isEven.js @@ -3,7 +3,6 @@ import { both, complement } from 'ramda'; import isInteger from './isInteger'; import isOdd from './isOdd'; - /** * Checks if value is even integer number. * An even number is an integer which is "evenly divisible" by two. diff --git a/src/isFalsy.js b/src/isFalsy.js index 3bc0d37f2c..29d9434503 100644 --- a/src/isFalsy.js +++ b/src/isFalsy.js @@ -2,7 +2,6 @@ import { complement } from 'ramda'; import isTruthy from './isTruthy'; - /** * A falsy value is a value that translates to false when evaluated in a Boolean context. * Falsy values are `false`, `0`, `""`, `null`, `undefined`, and `NaN`. diff --git a/src/isGeneratorFunction.js b/src/isGeneratorFunction.js index 18ca10e957..017d6c1a82 100644 --- a/src/isGeneratorFunction.js +++ b/src/isGeneratorFunction.js @@ -1,11 +1,9 @@ import isNotNull from './isNotNull'; - let GeneratorFunction = null; try { GeneratorFunction = new Function('return function* () {}')().constructor; // eslint-disable-line no-new-func -} catch (e) { } // eslint-disable-line no-empty - +} catch (e) {} // eslint-disable-line no-empty /* eslint-disable max-len */ /** @@ -27,9 +25,11 @@ try { * RA.isGeneratorFunction(() => {}); //=> false */ /* eslint-enable max-len */ -const isGeneratorFunction = (val) => { - const toStringCheck = Object.prototype.toString.call(val) === '[object GeneratorFunction]'; - const legacyConstructorCheck = isNotNull(GeneratorFunction) && val instanceof GeneratorFunction; +const isGeneratorFunction = val => { + const toStringCheck = + Object.prototype.toString.call(val) === '[object GeneratorFunction]'; + const legacyConstructorCheck = + isNotNull(GeneratorFunction) && val instanceof GeneratorFunction; return toStringCheck || legacyConstructorCheck; }; diff --git a/src/isNegative.js b/src/isNegative.js index f67f6d5a43..291a9cf985 100644 --- a/src/isNegative.js +++ b/src/isNegative.js @@ -2,7 +2,6 @@ import { both, gt } from 'ramda'; import isNumber from './isNumber'; - /** * Checks if value is a negative `Number` primitive or object. * diff --git a/src/isNonEmptyString.js b/src/isNonEmptyString.js index 8574d0cb03..7749e6f8b2 100644 --- a/src/isNonEmptyString.js +++ b/src/isNonEmptyString.js @@ -4,7 +4,6 @@ import isString from './isString'; import isNotObj from './isNotObj'; import isNotEmpty from './isNotEmpty'; - /** * Checks if input value is not an empty `String`. * diff --git a/src/isNotArrayLike.js b/src/isNotArrayLike.js index ad34fbbad8..5a862c8982 100644 --- a/src/isNotArrayLike.js +++ b/src/isNotArrayLike.js @@ -2,7 +2,6 @@ import { complement } from 'ramda'; import isArrayLike from './isArrayLike'; - /** * Tests whether or not an object is similar to an array. * diff --git a/src/isNotAsyncFunction.js b/src/isNotAsyncFunction.js index e476c48192..03a251ffd5 100644 --- a/src/isNotAsyncFunction.js +++ b/src/isNotAsyncFunction.js @@ -2,7 +2,6 @@ import { complement } from 'ramda'; import isAsyncFunction from './isAsyncFunction'; - /* eslint-disable max-len */ /** * Checks if input value is complement of `Async Function` diff --git a/src/isNotInteger.js b/src/isNotInteger.js index f3645575fb..b4301c3623 100644 --- a/src/isNotInteger.js +++ b/src/isNotInteger.js @@ -2,7 +2,6 @@ import { complement } from 'ramda'; import isInteger from './isInteger'; - /** * Checks whether the passed value is complement of an `integer`. * diff --git a/src/isNotNumber.js b/src/isNotNumber.js index 589e7e4761..ecd632b1ba 100644 --- a/src/isNotNumber.js +++ b/src/isNotNumber.js @@ -2,7 +2,6 @@ import { complement } from 'ramda'; import isNumber from './isNumber'; - /** * Checks if value is a complement of `Number` primitive or object. * diff --git a/src/isNotObj.js b/src/isNotObj.js index 3114205761..0fb50fb15e 100644 --- a/src/isNotObj.js +++ b/src/isNotObj.js @@ -2,7 +2,6 @@ import { complement } from 'ramda'; import isObj from './isObj'; - /* eslint-disable max-len */ /** * Checks if input value is complement of language type of `Object`. diff --git a/src/isNotObjLike.js b/src/isNotObjLike.js index 01ee383f0c..c18db62c62 100644 --- a/src/isNotObjLike.js +++ b/src/isNotObjLike.js @@ -2,7 +2,6 @@ import { complement } from 'ramda'; import isObjLike from './isObjLike'; - /* eslint-disable max-len */ /** * Checks if value is not object-like. A value is object-like if it's not null and has a typeof result of "object". diff --git a/src/isNotPair.js b/src/isNotPair.js index 4b85f3163c..fd3c15358e 100644 --- a/src/isNotPair.js +++ b/src/isNotPair.js @@ -2,7 +2,6 @@ import { complement } from 'ramda'; import isPair from './isPair'; - /** * Checks if input value is complement of a pair. * diff --git a/src/isObj.js b/src/isObj.js index 7538af04c0..7c99d851ad 100644 --- a/src/isObj.js +++ b/src/isObj.js @@ -4,7 +4,6 @@ import isNotNull from './isNotNull'; import isFunction from './isFunction'; import isOfTypeObject from './internal/isOfTypeObject'; - /* eslint-disable max-len */ /** * Checks if input value is language type of `Object`. diff --git a/src/isObjLike.js b/src/isObjLike.js index 0a5aabab51..a1b29be720 100644 --- a/src/isObjLike.js +++ b/src/isObjLike.js @@ -3,7 +3,6 @@ import { both } from 'ramda'; import isNotNull from './isNotNull'; import isOfTypeObject from './internal/isOfTypeObject'; - /* eslint-disable max-len */ /** * Checks if value is object-like. A value is object-like if it's not null and has a typeof result of "object". diff --git a/src/isOdd.js b/src/isOdd.js index 3a722fe86e..556f8dcd7f 100644 --- a/src/isOdd.js +++ b/src/isOdd.js @@ -2,7 +2,6 @@ import { both, pipe, modulo, flip, equals, complement } from 'ramda'; import isInteger from './isInteger'; - /** * Checks if value is odd integer number. * An odd number is an integer which is not a multiple DIVISIBLE of two. diff --git a/src/isPair.js b/src/isPair.js index 6d6c00012d..0a29caff0f 100644 --- a/src/isPair.js +++ b/src/isPair.js @@ -2,7 +2,6 @@ import { both, equals, length, pipe } from 'ramda'; import isArray from './isArray'; - /** * Checks if input value is a pair. * diff --git a/src/isPlainObj.js b/src/isPlainObj.js index c4424c14f0..138690b7bd 100644 --- a/src/isPlainObj.js +++ b/src/isPlainObj.js @@ -5,9 +5,11 @@ import isNull from './isNull'; import isObjLike from './isObjLike'; import isFunction from './isFunction'; - const isObjectConstructor = pipe(toString, equals(toString(Object))); -const hasObjectConstructor = pathSatisfies(both(isFunction, isObjectConstructor), ['constructor']); +const hasObjectConstructor = pathSatisfies( + both(isFunction, isObjectConstructor), + ['constructor'] +); /* eslint-disable max-len */ /** @@ -37,12 +39,16 @@ const hasObjectConstructor = pathSatisfies(both(isFunction, isObjectConstructor) * RA.isPlainObj(new Object()); //=> true */ /* eslint-enable max-len */ -const isPlainObj = (val) => { - if (!isObjLike(val) || !_isObject(val)) { return false } +const isPlainObj = val => { + if (!isObjLike(val) || !_isObject(val)) { + return false; + } const proto = Object.getPrototypeOf(val); - if (isNull(proto)) { return true } + if (isNull(proto)) { + return true; + } return hasObjectConstructor(proto); }; diff --git a/src/isPositive.js b/src/isPositive.js index 234779c7fb..fe1bbac2ad 100644 --- a/src/isPositive.js +++ b/src/isPositive.js @@ -2,7 +2,6 @@ import { both, lt } from 'ramda'; import isNumber from './isNumber'; - /** * Checks if value is a positive `Number` primitive or object. * diff --git a/src/isPromise.js b/src/isPromise.js index 50d3862db2..8ac499aca2 100644 --- a/src/isPromise.js +++ b/src/isPromise.js @@ -2,7 +2,6 @@ import { both, pipe, toString, equals } from 'ramda'; import isObj from './isObj'; - /** * Checks if input value is a native `Promise`. * The Promise object represents the eventual completion (or failure) diff --git a/src/isThenable.js b/src/isThenable.js index 2e6db91450..b68c1b318d 100644 --- a/src/isThenable.js +++ b/src/isThenable.js @@ -2,7 +2,6 @@ import { pathSatisfies } from 'ramda'; import isFunction from './isFunction'; - /** * Checks if input value is a `thenable`. * `thenable` is an object or function that defines a `then` method. diff --git a/src/isTruthy.js b/src/isTruthy.js index bf3b0e74e8..38f7feacdb 100644 --- a/src/isTruthy.js +++ b/src/isTruthy.js @@ -1,6 +1,5 @@ import { pipe, equals } from 'ramda'; - /** * In JavaScript, a `truthy` value is a value that is considered true * when evaluated in a Boolean context. All values are truthy unless diff --git a/src/lensEq.js b/src/lensEq.js index 3079cf1a35..80cd850b06 100644 --- a/src/lensEq.js +++ b/src/lensEq.js @@ -1,6 +1,5 @@ import { view, curryN, equals, pipe } from 'ramda'; - /** * Returns `true` if data structure focused by the given lens equals provided value. * @@ -22,7 +21,8 @@ import { view, curryN, equals, pipe } from 'ramda'; * RA.lensEq(R.lensIndex(1), 1, [0, 1, 2]); // => true * RA.lensEq(R.lensPath(['a', 'b']), 'foo', { a: { b: 'foo' } }) // => true */ -const lensEq = curryN(3, (lens, val, data) => pipe(view(lens), equals(val))(data)); - +const lensEq = curryN(3, (lens, val, data) => + pipe(view(lens), equals(val))(data) +); export default lensEq; diff --git a/src/lensIso.js b/src/lensIso.js index dfaae0d7f3..7ea9bb4e8e 100644 --- a/src/lensIso.js +++ b/src/lensIso.js @@ -1,12 +1,10 @@ import { curry, map } from 'ramda'; - // This implementation was highly inspired by the implementations // in ramda-lens library. // // https://github.com/ramda/ramda-lens - // isomorphic :: ((a -> b), (b -> a)) -> Isomorphism // Isomorphism = x -> y const isomorphic = (to, from) => { @@ -15,18 +13,16 @@ const isomorphic = (to, from) => { return isomorphism; }; - // isomorphisms :: ((a -> b), (b -> a)) -> (a -> b) -const isomorphisms = (to, from) => isomorphic( - curry((toFunctorFn, target) => map(from, toFunctorFn(to(target)))), - curry((toFunctorFn, target) => map(to, toFunctorFn(from(target)))) -); - +const isomorphisms = (to, from) => + isomorphic( + curry((toFunctorFn, target) => map(from, toFunctorFn(to(target)))), + curry((toFunctorFn, target) => map(to, toFunctorFn(from(target)))) + ); // from :: Isomorphism -> a -> b const from = curry((isomorphism, x) => isomorphism.from(x)); - /** * Defines an isomorphism that will work like a lens. It takes two functions. * The function that converts and the function that recovers. @@ -52,5 +48,4 @@ const from = curry((isomorphism, x) => isomorphism.from(x)); const lensIso = curry(isomorphisms); lensIso.from = from; - export default lensIso; diff --git a/src/lensNotEq.js b/src/lensNotEq.js index 5cc76356bb..ba5801d743 100644 --- a/src/lensNotEq.js +++ b/src/lensNotEq.js @@ -2,7 +2,6 @@ import { complement } from 'ramda'; import lensEq from './lensEq'; - /** * Returns `true` if data structure focused by the given lens doesn't equal provided value. * @@ -26,5 +25,4 @@ import lensEq from './lensEq'; */ const lensNotEq = complement(lensEq); - export default lensNotEq; diff --git a/src/lensNotSatisfy.js b/src/lensNotSatisfy.js index fdbe7ec43b..6735a7125a 100644 --- a/src/lensNotSatisfy.js +++ b/src/lensNotSatisfy.js @@ -2,7 +2,6 @@ import { complement } from 'ramda'; import lensSatisfies from './lensSatisfies'; - /** * Returns `true` if data structure focused by the given lens doesn't satisfy the predicate. * Note that the predicate is expected to return boolean value. @@ -28,5 +27,4 @@ import lensSatisfies from './lensSatisfies'; */ const lensNotSatisfy = complement(lensSatisfies); - export default lensNotSatisfy; diff --git a/src/lensSatisfies.js b/src/lensSatisfies.js index bf00248358..2c77c02458 100644 --- a/src/lensSatisfies.js +++ b/src/lensSatisfies.js @@ -1,6 +1,5 @@ import { view, curryN, equals, pipe } from 'ramda'; - /** * Returns `true` if data structure focused by the given lens satisfies the predicate. * Note that the predicate is expected to return boolean value and will be evaluated @@ -25,10 +24,8 @@ import { view, curryN, equals, pipe } from 'ramda'; * RA.lensSatisfies(R.equals(true), R.lensIndex(2), [false, true, 1]); // => false * RA.lensSatisfies(R.identity, R.lensProp('x'), { x: 1 }); // => false */ -const lensSatisfies = curryN( - 3, - (predicate, lens, data) => pipe(view(lens), predicate, equals(true))(data) +const lensSatisfies = curryN(3, (predicate, lens, data) => + pipe(view(lens), predicate, equals(true))(data) ); - export default lensSatisfies; diff --git a/src/mapIndexed.js b/src/mapIndexed.js index 9c7c6d6e26..543f5c1879 100644 --- a/src/mapIndexed.js +++ b/src/mapIndexed.js @@ -1,6 +1,5 @@ import { addIndex, map } from 'ramda'; - /** * {@link http://ramdajs.com/docs/#map|R.map} function that more closely resembles Array.prototype.map. * It takes two new parameters to its callback function: the current index, and the entire list. diff --git a/src/mergePath.js b/src/mergePath.js index c3ac9796a5..d1d8028b2b 100644 --- a/src/mergePath.js +++ b/src/mergePath.js @@ -25,6 +25,8 @@ import mergeRight from './mergeRight'; * { outer: { inner: { foo: 2 } } } * ); //=> { outer: { inner: { foo: 3, bar: 4 } } */ -const mergePath = curry((path, source, obj) => over(lensPath(path), mergeRight(source), obj)); +const mergePath = curry((path, source, obj) => + over(lensPath(path), mergeRight(source), obj) +); export default mergePath; diff --git a/src/neither.js b/src/neither.js index c60838e4ed..f44f9ff740 100644 --- a/src/neither.js +++ b/src/neither.js @@ -1,6 +1,5 @@ import { compose, complement, either } from 'ramda'; - /* eslint-disable max-len */ /** * A function which calls the two provided functions and returns the complement of `||`ing the diff --git a/src/nonePass.js b/src/nonePass.js index 8399863196..8e20bebec9 100644 --- a/src/nonePass.js +++ b/src/nonePass.js @@ -1,6 +1,5 @@ import { complement, compose, anyPass } from 'ramda'; - /** * Takes a list of predicates and returns a predicate that returns true for a given list of * arguments if none of the provided predicates are satisfied by those arguments. It is the diff --git a/src/notAllPass.js b/src/notAllPass.js index cb7e078a32..7941f815c1 100644 --- a/src/notAllPass.js +++ b/src/notAllPass.js @@ -1,6 +1,5 @@ import { complement, compose, allPass } from 'ramda'; - /** * Takes a list of predicates and returns a predicate that returns true for a given list of * arguments if one or more of the provided predicates is not satisfied by those arguments. It is diff --git a/src/notBoth.js b/src/notBoth.js index 51432e149c..631ad2d282 100644 --- a/src/notBoth.js +++ b/src/notBoth.js @@ -1,6 +1,5 @@ import { compose, complement, both } from 'ramda'; - /* eslint-disable max-len */ /** * A function which calls the two provided functions and returns the complement of `&&`ing the diff --git a/src/omitIndexes.js b/src/omitIndexes.js index 4a9460f6bd..554223ce37 100644 --- a/src/omitIndexes.js +++ b/src/omitIndexes.js @@ -1,11 +1,9 @@ import { contains, curry, addIndex, reject } from 'ramda'; - // helpers const rejectIndexed = addIndex(reject); const containsIndex = curry((indexes, val, index) => contains(index, indexes)); - /** * Returns a partial copy of an array omitting the indexes specified. * @@ -22,6 +20,8 @@ const containsIndex = curry((indexes, val, index) => contains(index, indexes)); * * RA.omitIndexes([-1, 1, 3], ['a', 'b', 'c', 'd']); //=> ['a', 'c'] */ -const omitIndexes = curry((indexes, list) => rejectIndexed(containsIndex(indexes), list)); +const omitIndexes = curry((indexes, list) => + rejectIndexed(containsIndex(indexes), list) +); export default omitIndexes; diff --git a/src/pathNotEq.js b/src/pathNotEq.js index cedeea1010..5119fd668e 100644 --- a/src/pathNotEq.js +++ b/src/pathNotEq.js @@ -1,6 +1,5 @@ import { pathEq, complement } from 'ramda'; - /* eslint-disable max-len */ /** * Determines whether a nested path on an object doesn't have a specific value, diff --git a/src/pickIndexes.js b/src/pickIndexes.js index 33cc8fc74b..52d1e38ee3 100644 --- a/src/pickIndexes.js +++ b/src/pickIndexes.js @@ -1,11 +1,9 @@ import { filter, addIndex, curry, contains } from 'ramda'; - // helpers const filterIndexed = addIndex(filter); const containsIndex = curry((indexes, val, index) => contains(index, indexes)); - /** * Picks values from list by indexes. * @@ -22,6 +20,8 @@ const containsIndex = curry((indexes, val, index) => contains(index, indexes)); * * RA.pickIndexes([0, 2], ['a', 'b', 'c']); //=> ['a', 'c'] */ -const pickIndexes = curry((indexes, list) => filterIndexed(containsIndex(indexes), list)); +const pickIndexes = curry((indexes, list) => + filterIndexed(containsIndex(indexes), list) +); export default pickIndexes; diff --git a/src/propNotEq.js b/src/propNotEq.js index 5d1b3dd900..6aa062b162 100644 --- a/src/propNotEq.js +++ b/src/propNotEq.js @@ -1,6 +1,5 @@ import { propEq, complement } from 'ramda'; - /** * Returns true if the specified object property is not equal, * in R.equals terms, to the given value; false otherwise. diff --git a/src/reduceIndexed.js b/src/reduceIndexed.js index 9f6664f2c6..0fb9be094b 100644 --- a/src/reduceIndexed.js +++ b/src/reduceIndexed.js @@ -1,6 +1,5 @@ import { addIndex, reduce } from 'ramda'; - /** * {@link http://ramdajs.com/docs/#reduce|R.reduce} function that more closely resembles Array.prototype.reduce. * It takes two new parameters to its callback function: the current index, and the entire list. diff --git a/src/reduceP.js b/src/reduceP.js index 20f7c1af37..2118a3794d 100644 --- a/src/reduceP.js +++ b/src/reduceP.js @@ -69,24 +69,28 @@ import allP from './allP'; * */ /* esline-enable max-len */ -const reduceP = curryN(3, (fn, acc, list) => resolveP(list) - .then((iterable) => { +const reduceP = curryN(3, (fn, acc, list) => + resolveP(list).then(iterable => { const listLength = length(iterable); - if (listLength === 0) { return acc } + if (listLength === 0) { + return acc; + } - const reducer = reduce((accP, currentValueP) => accP - .then(previousValue => allP([previousValue, currentValueP])) - .then(([previousValue, currentValue]) => { - if (isUndefined(previousValue) && listLength === 1) { - return currentValue; - } + const reducer = reduce((accP, currentValueP) => + accP + .then(previousValue => allP([previousValue, currentValueP])) + .then(([previousValue, currentValue]) => { + if (isUndefined(previousValue) && listLength === 1) { + return currentValue; + } - return fn(previousValue, currentValue); - })); + return fn(previousValue, currentValue); + }) + ); return reducer(resolveP(acc), iterable); - })); - + }) +); export default reduceP; diff --git a/src/reduceRightP.js b/src/reduceRightP.js index 3ab4d2db0b..d3fe9df66f 100644 --- a/src/reduceRightP.js +++ b/src/reduceRightP.js @@ -4,11 +4,9 @@ import isUndefined from './isUndefined'; import resolveP from './resolveP'; import allP from './allP'; - // in older ramda versions the order of the arguments is flipped const flipArgs = pipe(reduceRight(concat, ''), equals('ba'))(['a', 'b']); - /* eslint-disable max-len */ /** * Given an `Iterable`(arrays are `Iterable`), or a promise of an `Iterable`, @@ -67,20 +65,22 @@ const flipArgs = pipe(reduceRight(concat, ''), equals('ba'))(['a', 'b']); * */ /* esline-enable max-len */ -const reduceRightP = curryN(3, (fn, acc, list) => resolveP(list) - .then((iterable) => { +const reduceRightP = curryN(3, (fn, acc, list) => + resolveP(list).then(iterable => { const listLength = length(iterable); - if (listLength === 0) { return acc } + if (listLength === 0) { + return acc; + } const reducer = reduceRight((arg1, arg2) => { let accP; let currentValueP; if (flipArgs) { - ([accP, currentValueP] = [arg1, arg2]); + [accP, currentValueP] = [arg1, arg2]; } else { - ([accP, currentValueP] = [arg2, arg1]); + [accP, currentValueP] = [arg2, arg1]; } return accP @@ -95,7 +95,7 @@ const reduceRightP = curryN(3, (fn, acc, list) => resolveP(list) }); return reducer(resolveP(acc), iterable); - })); - + }) +); export default reduceRightP; diff --git a/src/renameKeys.js b/src/renameKeys.js index 6b9e665f1c..ad05e4c744 100644 --- a/src/renameKeys.js +++ b/src/renameKeys.js @@ -2,8 +2,7 @@ import { curry, has } from 'ramda'; import renameKeysWith from './renameKeysWith'; - -const valueOrKey = keysMap => (key) => { +const valueOrKey = keysMap => key => { if (has(key, keysMap)) { return keysMap[key]; } @@ -34,6 +33,8 @@ const valueOrKey = keysMap => (key) => { * RA.renameKeys({ firstName: 'name', type: 'kind', foo: 'bar' })(input); * //=> { name: 'Elisia', age: 22, kind: 'human' } */ -const renameKeys = curry((keysMap, obj) => renameKeysWith(valueOrKey(keysMap), obj)); +const renameKeys = curry((keysMap, obj) => + renameKeysWith(valueOrKey(keysMap), obj) +); export default renameKeys; diff --git a/src/renameKeysWith.js b/src/renameKeysWith.js index 143d4001c4..fe0c68bb4b 100644 --- a/src/renameKeysWith.js +++ b/src/renameKeysWith.js @@ -20,6 +20,8 @@ import { curry, toPairs, pipe, map, adjust, fromPairs } from 'ramda'; * * RA.renameKeysWith(R.concat('a'), { A: 1, B: 2, C: 3 }) //=> { aA: 1, aB: 2, aC: 3 } */ -const renameKeysWith = curry((fn, obj) => pipe(toPairs, map(adjust(fn, 0)), fromPairs)(obj)); +const renameKeysWith = curry((fn, obj) => + pipe(toPairs, map(adjust(fn, 0)), fromPairs)(obj) +); export default renameKeysWith; diff --git a/src/viewOr.js b/src/viewOr.js index bc443ee072..34585b7f39 100644 --- a/src/viewOr.js +++ b/src/viewOr.js @@ -1,6 +1,5 @@ import { view, defaultTo, curryN } from 'ramda'; - /** * Returns a "view" of the given data structure, determined by the given lens. * The lens's focus determines which portion of the data structure is visible. @@ -26,10 +25,8 @@ import { view, defaultTo, curryN } from 'ramda'; * RA.viewOr('some', R.lensProp('y'), { y: false }); // => false */ -const viewOr = curryN( - 3, - (defaultValue, lens, data) => defaultTo(defaultValue, view(lens, data)) +const viewOr = curryN(3, (defaultValue, lens, data) => + defaultTo(defaultValue, view(lens, data)) ); - export default viewOr; diff --git a/src/weave.js b/src/weave.js index f7365be8c3..5357260942 100644 --- a/src/weave.js +++ b/src/weave.js @@ -28,6 +28,8 @@ import { curryN } from 'ramda'; * const wlog = RA.weave(log, console); * wlog('test'); //=> prints 'test' */ -const weave = curryN(2, (fn, config) => curryN(fn.length, (...args) => fn(...args).run(config))); +const weave = curryN(2, (fn, config) => + curryN(fn.length, (...args) => fn(...args).run(config)) +); export default weave; diff --git a/src/weaveLazy.js b/src/weaveLazy.js index 1509385ae7..32d32674b8 100644 --- a/src/weaveLazy.js +++ b/src/weaveLazy.js @@ -30,9 +30,8 @@ import { curryN } from 'ramda'; * const wlog = RA.weaveLazy(log, consoleAccessor); * wlog('test'); //=> prints 'test' */ -const weaveLazy = curryN( - 2, - (fn, configAccessor) => curryN(fn.length, (...args) => fn(...args).run(configAccessor())) +const weaveLazy = curryN(2, (fn, configAccessor) => + curryN(fn.length, (...args) => fn(...args).run(configAccessor())) ); export default weaveLazy; diff --git a/test/Y.js b/test/Y.js index 9fd27c4698..e5bac6f83a 100644 --- a/test/Y.js +++ b/test/Y.js @@ -1,11 +1,12 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('Y', function () { - it('tests for making a factorial function', function () { - const makeFact = givenFact => (n) => { - if (n < 2) { return 1 } +describe('Y', function() { + it('tests for making a factorial function', function() { + const makeFact = givenFact => n => { + if (n < 2) { + return 1; + } return n * givenFact(n - 1); }; diff --git a/test/allP.js b/test/allP.js index 0df87bb4e8..db328e8645 100644 --- a/test/allP.js +++ b/test/allP.js @@ -2,29 +2,28 @@ import { assert } from 'chai'; import * as RA from '../src/index'; - -describe('allP', function () { - context('when no arguments', function () { - specify('throws TypeError', function (done) { +describe('allP', function() { + context('when no arguments', function() { + specify('throws TypeError', function(done) { assert.isRejected(RA.allP(), Error).notify(done); }); }); - it('tests resolving list of thenable values', function (done) { + it('tests resolving list of thenable values', function(done) { const p1 = RA.resolveP(1); const p2 = RA.resolveP(2); assert.eventually.deepEqual(RA.allP([p1, p2]), [1, 2]).notify(done); }); - it('tests resolving list of mixed thenable and non-thenable values', function (done) { + it('tests resolving list of mixed thenable and non-thenable values', function(done) { const p1 = RA.resolveP(1); const p2 = 2; assert.eventually.deepEqual(RA.allP([p1, p2]), [1, 2]).notify(done); }); - it('tests resolving list of rejected thenable values', function (done) { + it('tests resolving list of rejected thenable values', function(done) { const p1 = RA.resolveP(1); const p2 = RA.rejectP(2); @@ -32,17 +31,17 @@ describe('allP', function () { }); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all#Promise.all_fail-fast_behaviour - it('tests fail-fast behavior', function (done) { - const p1 = new Promise((resolve) => { + it('tests fail-fast behavior', function(done) { + const p1 = new Promise(resolve => { setTimeout(resolve, 10, 'one'); }); - const p2 = new Promise((resolve) => { + const p2 = new Promise(resolve => { setTimeout(resolve, 20, 'two'); }); - const p3 = new Promise((resolve) => { + const p3 = new Promise(resolve => { setTimeout(resolve, 30, 'three'); }); - const p4 = new Promise((resolve) => { + const p4 = new Promise(resolve => { setTimeout(resolve, 40, 'four'); }); const p5 = new Promise((resolve, reject) => { @@ -52,8 +51,8 @@ describe('allP', function () { assert.isRejected(RA.allP([p1, p2, p3, p4, p5]), Error).notify(done); }); - context('when there are two rejections', function () { - specify('should reject with the first one', function (done) { + context('when there are two rejections', function() { + specify('should reject with the first one', function(done) { const p1 = RA.resolveP(1); const p2 = RA.rejectP(1); const p3 = RA.rejectP(2); diff --git a/test/appendFlipped.js b/test/appendFlipped.js index 9f3fbf5ec8..6f650bd7c5 100644 --- a/test/appendFlipped.js +++ b/test/appendFlipped.js @@ -1,14 +1,13 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('appendFlipped', function () { - it('adds the element to the end of the list', function () { +describe('appendFlipped', function() { + it('adds the element to the end of the list', function() { eq(RA.appendFlipped(['x', 'y'], 'z'), ['x', 'y', 'z']); eq(RA.appendFlipped(['x', 'y'], ['a', 'z']), ['x', 'y', ['a', 'z']]); }); - it('works on empty list', function () { + it('works on empty list', function() { eq(RA.appendFlipped([], 1), [1]); }); }); diff --git a/test/cata.js b/test/cata.js index 72a382f9fe..bf292c99a4 100644 --- a/test/cata.js +++ b/test/cata.js @@ -5,32 +5,31 @@ import chai from 'chai'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('cata', function () { +describe('cata', function() { const eitherR = Either.Right(1); const eitherL = Either.Left(2); - it('tests an Either for catamorphism', function () { + it('tests an Either for catamorphism', function() { eq(RA.cata(identity, identity, eitherR), 1); eq(RA.cata(identity, identity, eitherL), 2); }); - it('test currying', function () { + it('test currying', function() { eq(RA.cata(identity)(identity)(eitherR), 1); eq(RA.cata(identity, identity)(eitherL), 2); }); - it('tests left for catamorphism without functions', function () { + it('tests left for catamorphism without functions', function() { chai.assert.throws(RA.cata.bind(null, null, identity, eitherL), TypeError); eq(RA.cata(identity, null, eitherL), 2); }); - it('tests right for catamorphism without functions', function () { + it('tests right for catamorphism without functions', function() { chai.assert.throws(RA.cata.bind(null, identity, null, eitherR), TypeError); eq(RA.cata(null, identity, eitherR), 1); }); - it('test catamorphism on either method', function () { + it('test catamorphism on either method', function() { const eitherRWithEither = Either.Right(1); const eitherLWithEither = Either.Left(2); @@ -41,9 +40,12 @@ describe('cata', function () { eq(RA.cata(identity, identity, eitherLWithEither), 2); }); - it('tests on monad without catamorphic behavior', function () { + it('tests on monad without catamorphic behavior', function() { chai.assert.throws(RA.cata.bind(null, identity, identity, {}), TypeError); chai.assert.throws(RA.cata.bind(null, identity, identity, null), TypeError); - chai.assert.throws(RA.cata.bind(null, identity, identity, undefined), TypeError); + chai.assert.throws( + RA.cata.bind(null, identity, identity, undefined), + TypeError + ); }); }); diff --git a/test/compact.js b/test/compact.js index 7347d1f368..ddbcf40edc 100644 --- a/test/compact.js +++ b/test/compact.js @@ -3,28 +3,27 @@ import { assert } from 'chai'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('compact', function () { - context('when list contains falsy values', function () { - specify('should filter them', function () { +describe('compact', function() { + context('when list contains falsy values', function() { + specify('should filter them', function() { eq(RA.compact([0, 1, false, 2, '', 3, null, undefined, NaN]), [1, 2, 3]); }); }); - context('when list contains truthy values only', function () { - specify('should not filter anything', function () { + context('when list contains truthy values only', function() { + specify('should not filter anything', function() { eq(RA.compact([1, 2, 3]), [1, 2, 3]); }); - specify('should return new list with exactly same items', function () { + specify('should return new list with exactly same items', function() { const list = [1, 2, 3]; assert.notStrictEqual(RA.compact(list), list); }); }); - context('when empty list', function () { - specify('should return new empty list', function () { + context('when empty list', function() { + specify('should return new empty list', function() { const list = []; assert.notStrictEqual(RA.compact(list), list); diff --git a/test/concatRight.js b/test/concatRight.js index e9c31cb35f..d3d401493d 100644 --- a/test/concatRight.js +++ b/test/concatRight.js @@ -4,47 +4,48 @@ import chai from 'chai'; import eq from './shared/eq'; import * as RA from '../src/index'; - -describe('concatRight', function () { +describe('concatRight', function() { const z1 = { x: 'z1', - concat(that) { return this.x + ' ' + that.x }, // eslint-disable-line prefer-template + concat(that) { + return `${this.x} ${that.x}`; + }, // eslint-disable-line prefer-template }; const z2 = { x: 'z2' }; - it('adds combines the elements of the two lists', function () { + it('adds combines the elements of the two lists', function() { eq(RA.concatRight(['a', 'b'], ['c', 'd']), ['c', 'd', 'a', 'b']); eq(RA.concatRight([], ['c', 'd']), ['c', 'd']); }); - it('works on strings', function () { + it('works on strings', function() { eq(RA.concatRight('foo', 'bar'), 'barfoo'); eq(RA.concatRight('x', ''), 'x'); eq(RA.concatRight('', 'x'), 'x'); eq(RA.concatRight('', ''), ''); }); - it('delegates to non-String object with a concat method, as first param', function () { + it('delegates to non-String object with a concat method, as first param', function() { eq(RA.concatRight(z2, z1), 'z1 z2'); }); - it('is curried', function () { + it('is curried', function() { const conc123 = RA.concatRight([1, 2, 3]); eq(conc123([4, 5, 6]), [4, 5, 6, 1, 2, 3]); eq(conc123(['a', 'b', 'c']), ['a', 'b', 'c', 1, 2, 3]); }); - it('is curried like a binary operator, that accepts an initial placeholder', function () { + it('is curried like a binary operator, that accepts an initial placeholder', function() { const appendBar = RA.concatRight(R.__, 'bar'); eq(typeof appendBar, 'function'); eq(appendBar('foo'), 'barfoo'); }); - it('throws if attempting to combine an array with a non-array', function () { + it('throws if attempting to combine an array with a non-array', function() { chai.assert.throws(RA.concatRight.bind(null, [1], 2), TypeError); }); - it('throws if not an array, String, or object with a concat method', function () { + it('throws if not an array, String, or object with a concat method', function() { chai.assert.throws(RA.concatRight.bind(null, {}, {}), TypeError); }); }); diff --git a/test/curryRight.js b/test/curryRight.js index 097c5cdc0e..941ea62b37 100644 --- a/test/curryRight.js +++ b/test/curryRight.js @@ -4,28 +4,31 @@ import jsv from 'jsverify'; import eq from './shared/eq'; import * as RA from '../src/index'; - -describe('curryRight', function () { - it('curries a single value', function () { - const f = RA.curryRight(function (a, b, c, d) { - return (a + (b * c)) / d; +describe('curryRight', function() { + it('curries a single value', function() { + const f = RA.curryRight(function(a, b, c, d) { + return (a + b * c) / d; }); // f(2, 6, 3, 10) == 2 const g = f(10); eq(g(3, 6, 2), 2); }); - it('curries multiple values', function () { + it('curries multiple values', function() { // f(2, 6, 3, 10) == 2 - const f = RA.curryRight(function (a, b, c, d) { return (a + (b * c)) / d }); + const f = RA.curryRight(function(a, b, c, d) { + return (a + b * c) / d; + }); const g = f(10, 3); eq(g(6, 2), 2); const h = f(10, 3, 6); eq(h(2), 2); }); - it('allows further currying of a curried function', function () { + it('allows further currying of a curried function', function() { // f(2, 6, 3, 10) == 2 - const f = RA.curryRight(function (a, b, c, d) { return (a + (b * c)) / d }); + const f = RA.curryRight(function(a, b, c, d) { + return (a + b * c) / d; + }); const g = f(10); eq(g(3, 6, 2), 2); const h = g(3); @@ -33,8 +36,10 @@ describe('curryRight', function () { eq(g(3, 6)(2), 2); }); - it('properly reports the length of the curried function', function () { - const f = RA.curryRight(function (a, b, c, d) { return (a + (b * c)) / d }); + it('properly reports the length of the curried function', function() { + const f = RA.curryRight(function(a, b, c, d) { + return (a + b * c) / d; + }); eq(f.length, 4); const g = f(10); eq(g.length, 3); @@ -43,18 +48,21 @@ describe('curryRight', function () { eq(g(3, 6).length, 1); }); - it('preserves context', function () { + it('preserves context', function() { const ctx = { x: 10 }; - const f = function (a, b) { return a + (b * this.x) }; + const f = function(a, b) { + return a + b * this.x; + }; const g = RA.curryRight(f); eq(g.call(ctx, 2, 4), 24); eq(g.call(ctx, 2).call(ctx, 4), 24); }); - - it('supports R.__ placeholder', function () { - const f = function (a, b, c) { return [a, b, c] }; + it('supports R.__ placeholder', function() { + const f = function(a, b, c) { + return [a, b, c]; + }; const g = RA.curryRight(f); const _ = R.__; @@ -83,8 +91,10 @@ describe('curryRight', function () { eq(g(_, _, _)(1, _, _)(_, _)(2, _)(_)(3), [3, 2, 1]); }); - it('supports @@functional/placeholder', function () { - const f = function (a, b, c) { return [a, b, c] }; + it('supports @@functional/placeholder', function() { + const f = function(a, b, c) { + return [a, b, c]; + }; const g = RA.curryRight(f); const _ = { '@@functional/placeholder': true, x: Math.random() }; @@ -113,8 +123,8 @@ describe('curryRight', function () { eq(g(_, _, _)(1, _, _)(_, _)(2, _)(_)(3), [3, 2, 1]); }); - it('forwards extra arguments', function () { - const f = function (a, b, c) { + it('forwards extra arguments', function() { + const f = function(a, b, c) { void c; return Array.prototype.slice.call(arguments); }; @@ -129,32 +139,44 @@ describe('curryRight', function () { }); /* eslint-disable max-len */ -describe('curryRight properties', function () { - jsv.property('curries multiple values', jsv.integer, jsv.integer, jsv.integer, (a, b, c) => { - const f = (_a, _b, _c) => _a + _b + _c; - const g = RA.curryRight(f); - - return R.all(R.equals(f(a, b, c)), [ - g(a, b, c), - g(a)(b)(c), - g(a)(b, c), - g(a, b)(c), - g(a, b, c), - ]); - }); - - jsv.property('curries with placeholder', jsv.integer, jsv.integer, jsv.integer, (a, b, c) => { - const _ = { '@@functional/placeholder': true, x: Math.random() }; - const f = (_a, _b, _c) => _a + _b + _c; - const g = RA.curryRight(f); - - return R.all(R.equals(f(a, b, c)), [ - g(_, _, c)(a, b), - g(a, _, c)(b), - g(_, b, c)(a), - g(a, _, _)(_, c)(b), - g(a, b, _)(c), - ]); - }); +describe('curryRight properties', function() { + jsv.property( + 'curries multiple values', + jsv.integer, + jsv.integer, + jsv.integer, + (a, b, c) => { + const f = (_a, _b, _c) => _a + _b + _c; + const g = RA.curryRight(f); + + return R.all(R.equals(f(a, b, c)), [ + g(a, b, c), + g(a)(b)(c), + g(a)(b, c), + g(a, b)(c), + g(a, b, c), + ]); + } + ); + + jsv.property( + 'curries with placeholder', + jsv.integer, + jsv.integer, + jsv.integer, + (a, b, c) => { + const _ = { '@@functional/placeholder': true, x: Math.random() }; + const f = (_a, _b, _c) => _a + _b + _c; + const g = RA.curryRight(f); + + return R.all(R.equals(f(a, b, c)), [ + g(_, _, c)(a, b), + g(a, _, c)(b), + g(_, b, c)(a), + g(a, _, _)(_, c)(b), + g(a, b, _)(c), + ]); + } + ); }); /* eslint-enable */ diff --git a/test/curryRightN.js b/test/curryRightN.js index 47f5a6745a..23c6e43600 100644 --- a/test/curryRightN.js +++ b/test/curryRightN.js @@ -3,14 +3,13 @@ import * as R from 'ramda'; import eq from './shared/eq'; import * as RA from '../src/index'; - -describe('curryRightN', function () { +describe('curryRightN', function() { const source = (a, b, c, d) => { void d; return a * b * c; }; - it('accepts an arity', function () { + it('accepts an arity', function() { const curried = RA.curryRightN(3, source); eq(curried(1)(2)(3), 6); eq(curried(1, 2)(3), 6); @@ -18,7 +17,7 @@ describe('curryRightN', function () { eq(curried(1, 2, 3), 6); }); - it('can be partially applied', function () { + it('can be partially applied', function() { const curryRight3 = RA.curryRightN(3); const curried = curryRight3(source); eq(curried.length, 3); @@ -28,17 +27,21 @@ describe('curryRightN', function () { eq(curried(1, 2, 3), 6); }); - it('preserves context', function () { + it('preserves context', function() { const ctx = { x: 10 }; - const f = function (a, b) { return a + (b * this.x) }; + const f = function(a, b) { + return a + b * this.x; + }; const g = RA.curryRightN(2, f); eq(g.call(ctx, 2, 4), 24); eq(g.call(ctx, 2).call(ctx, 4), 24); }); - it('supports R.__ placeholder', function () { - const f = function (...args) { return args }; + it('supports R.__ placeholder', function() { + const f = function(...args) { + return args; + }; const g = RA.curryRightN(3, f); const _ = R.__; @@ -67,8 +70,10 @@ describe('curryRightN', function () { eq(g(_, _, _)(1, _, _)(_, _)(2, _)(_)(3), [3, 2, 1]); }); - it('supports @@functional/placeholder', function () { - const f = function () { return Array.prototype.slice.call(arguments) }; + it('supports @@functional/placeholder', function() { + const f = function() { + return Array.prototype.slice.call(arguments); + }; const g = RA.curryRightN(3, f); const _ = { '@@functional/placeholder': true, x: Math.random() }; @@ -97,8 +102,10 @@ describe('curryRightN', function () { eq(g(_, _, _)(1, _, _)(_, _)(2, _)(_)(3), [3, 2, 1]); }); - it('forwards extra arguments', function () { - const f = function () { return Array.prototype.slice.call(arguments) }; + it('forwards extra arguments', function() { + const f = function() { + return Array.prototype.slice.call(arguments); + }; const g = RA.curryRightN(3, f); eq(g(1, 2, 3), [3, 2, 1]); diff --git a/test/defaultWhen.js b/test/defaultWhen.js index c78d07bcf9..cf9f5e9bc1 100644 --- a/test/defaultWhen.js +++ b/test/defaultWhen.js @@ -1,19 +1,18 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('defaultWhen', function () { - it('tests returning default value', function () { +describe('defaultWhen', function() { + it('tests returning default value', function() { eq(RA.defaultWhen(RA.isNull, 1, null), 1); eq(RA.defaultWhen(RA.isString, 2, ''), 2); }); - it('tests returning value', function () { + it('tests returning value', function() { eq(RA.defaultWhen(RA.isNull, 1, undefined), undefined); eq(RA.defaultWhen(RA.isString, 2, 3), 3); }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.defaultWhen(RA.isNull)(1)(null), 1); eq(RA.defaultWhen(RA.isNull, 1)(null), 1); eq(RA.defaultWhen(RA.isNull, 1, null), 1); diff --git a/test/fantasy-land/Identity.js b/test/fantasy-land/Identity.js index 039435487d..e5ce8faf10 100644 --- a/test/fantasy-land/Identity.js +++ b/test/fantasy-land/Identity.js @@ -15,29 +15,28 @@ import contravarian from 'fantasy-land/laws/contravariant'; import { isFunction, Identity } from '../../src/index'; import eq from '../shared/eq'; - -describe('Identity', function () { - describe('Setoid', function () { - it('tests for reflexivity', function () { +describe('Identity', function() { + describe('Setoid', function() { + it('tests for reflexivity', function() { setoid.reflexivity(Identity.of)(eq)(1); }); - it('tests for symetry', function () { + it('tests for symetry', function() { setoid.symmetry(Identity.of)(eq)(1); }); - it('tests for transitivity', function () { + it('tests for transitivity', function() { setoid.transitivity(Identity.of)(eq)(1); }); - it('tests for value of the same Setoid', function () { + it('tests for value of the same Setoid', function() { const a = Identity.of(1); const b = Identity.of(1); eq(a.equals(b), true); }); - it('tests for value of different Setoid', function () { + it('tests for value of different Setoid', function() { const a = Identity.of(1); const b = Identity.of(1); @@ -46,7 +45,7 @@ describe('Identity', function () { eq(a.equals(b), false); }); - it('tests for returning a boolean', function () { + it('tests for returning a boolean', function() { const a = Identity.of(1); const b = Identity.of(2); @@ -54,7 +53,7 @@ describe('Identity', function () { eq(a.equals(b), false); }); - it('tests isomorphism', function () { + it('tests isomorphism', function() { const type = Identity.of(1); const value = type.get(); @@ -63,19 +62,19 @@ describe('Identity', function () { }); }); - describe('Semigroup', function () { - it('tests for associativity', function () { + describe('Semigroup', function() { + it('tests for associativity', function() { semigroup.associativity(Identity.of)(eq)(1); }); - it('tests for value of different Semigroup', function () { + it('tests for value of different Semigroup', function() { const a = Identity.of({}); const b = Identity.of([]); chai.assert.throws(a.concat.bind(b), TypeError); }); - it('tests concat for returning a value of the same Setoid', function () { + it('tests concat for returning a value of the same Setoid', function() { const a = Identity.of(1); const b = Identity.of(2); const c = a.concat(b); @@ -85,7 +84,7 @@ describe('Identity', function () { eq(c instanceof Identity, true); }); - it('tests concat on number Semigroup', function () { + it('tests concat on number Semigroup', function() { const a = Identity.of(1); const b = Identity.of(2); const c = a.concat(b); @@ -93,7 +92,7 @@ describe('Identity', function () { eq(c.get(), 3); }); - it('tests concat on string Semigroup', function () { + it('tests concat on string Semigroup', function() { const a = Identity.of('a'); const b = Identity.of('b'); const c = a.concat(b); @@ -101,7 +100,7 @@ describe('Identity', function () { eq(c.get(), 'ab'); }); - it('tests concat on array Semigroup', function () { + it('tests concat on array Semigroup', function() { const a = Identity.of([1]); const b = Identity.of([2]); const c = a.concat(b); @@ -109,7 +108,7 @@ describe('Identity', function () { eq(c.get(), [1, 2]); }); - it('test concat of fantas-land compatible Semigroup', function () { + it('test concat of fantas-land compatible Semigroup', function() { const arrayA = [1]; const arrayB = [2]; @@ -124,88 +123,88 @@ describe('Identity', function () { }); }); - describe('Apply', function () { - it('tests for Functor spec', function () { + describe('Apply', function() { + it('tests for Functor spec', function() { const a = Identity.of(1); eq(isFunction(a[fl.map]), true); }); - it('tests for composition', function () { + it('tests for composition', function() { apply.composition(Identity)(eq)(1); }); - it('test ap argument for an apply of a function', function () { + it('test ap argument for an apply of a function', function() { const a = Identity.of(1); const b = Identity.of(1).map(add); eq(a.ap(b).get(), 2); }); - it('test ap argument for an apply of a non-function', function () { + it('test ap argument for an apply of a non-function', function() { const a = Identity.of(1); const b = Identity.of(1).map(identity); chai.assert.throws(() => a.ap(b).get(), TypeError); }); - it('test ap caller for an apply of any value', function () { + it('test ap caller for an apply of any value', function() { const a = Identity.of(NaN); const b = Identity.of(1).map(add); eq(a.ap(b).get(), NaN); }); - it('test for non parts or return value being checked', function () { + it('test for non parts or return value being checked', function() { // TODO(vladimir.gorej@gmail.com): how to tests this one ? }); }); - describe('Applicative', function () { - it('tests for an Apply spec', function () { + describe('Applicative', function() { + it('tests for an Apply spec', function() { const a = Identity.of(1); eq(isFunction(a[fl.ap]), true); }); - it('tests for identity', function () { + it('tests for identity', function() { applicative.identity(Identity)(eq)(1); }); - it('tests for homomorphism', function () { + it('tests for homomorphism', function() { applicative.homomorphism(Identity)(eq)(1); }); - it('tests for interchange', function () { + it('tests for interchange', function() { applicative.interchange(Identity)(eq)(1); }); - it('tests for of function on type representative', function () { + it('tests for of function on type representative', function() { eq(isFunction(Identity[fl.of]), true); eq(Identity.of(1).constructor[fl.of], Identity[fl.of]); }); - it('tests for of providing value of same Applicative', function () { + it('tests for of providing value of same Applicative', function() { const a = Identity.of(1); eq(a instanceof Identity, true); }); - it("tests if no parts of of's arguments are being checked", function () { + it("tests if no parts of of's arguments are being checked", function() { // TODO(vladimir.gorej@gmail.com): how to tests this one ? }); }); - describe('Functor', function () { - it('tests for identity', function () { + describe('Functor', function() { + it('tests for identity', function() { functor.identity(Identity.of)(eq)(1); }); - it('tests for composition', function () { + it('tests for composition', function() { functor.composition(Identity.of)(eq)(identity)(identity)(1); }); - it('tests f for a function type', function () { + it('tests f for a function type', function() { const fn = sinon.spy(); const a = Identity.of(1).map(fn); @@ -214,14 +213,14 @@ describe('Identity', function () { eq(fn.calledWith(1), true); }); - it('tests f for non-function type and unspecified behavior', function () { + it('tests f for non-function type and unspecified behavior', function() { const fn = null; const a = Identity.of(1); chai.assert.throws(a.map.bind(a, fn), TypeError); }); - it('tests f for returning any value', function () { + it('tests f for returning any value', function() { const stubNull = () => null; const stubUndefined = () => undefined; const stubNumber = () => 1; @@ -235,7 +234,7 @@ describe('Identity', function () { eq(a.map(stubString).get(), 'string'); }); - it("tests for non parts of f's return value should be checked", function () { + it("tests for non parts of f's return value should be checked", function() { const result = {}; const a = Identity.of(result).map(identity); @@ -244,7 +243,7 @@ describe('Identity', function () { eq(a.get(), result); }); - it('tests map for returning a value of the same Functor', function () { + it('tests map for returning a value of the same Functor', function() { const a = Identity.of(1); const b = a.map(identity); @@ -253,18 +252,18 @@ describe('Identity', function () { }); }); - describe('Contravariant', function () { + describe('Contravariant', function() { const contramapEq = (a, b) => eq(a.get()(1), b.get()(1)); - it('tests for identity', function () { + it('tests for identity', function() { contravarian.identity(Identity.of)(contramapEq)(identity); }); - it('tests for composition', function () { + it('tests for composition', function() { contravarian.composition(Identity.of)(contramapEq)(always(1)); }); - it('tests f for a function type', function () { + it('tests f for a function type', function() { const fn = sinon.spy(); const a = Identity.of(always(1)).contramap(fn); @@ -275,14 +274,14 @@ describe('Identity', function () { eq(fn.calledWith(2), true); }); - it('tests f for non-function type and unspecified behavior', function () { + it('tests f for non-function type and unspecified behavior', function() { const fn = null; const a = Identity.of(identity); chai.assert.throws(() => a.contramap(fn).get()(), TypeError); }); - it('tests f for returning any value', function () { + it('tests f for returning any value', function() { const stubNull = () => null; const stubUndefined = () => undefined; const stubNumber = () => 1; @@ -296,7 +295,7 @@ describe('Identity', function () { eq(a.contramap(stubString).get()(), 'string'); }); - it("tests for non parts of f's return value should be checked", function () { + it("tests for non parts of f's return value should be checked", function() { const result = {}; const a = Identity.of(identity).contramap(always(result)); @@ -305,7 +304,7 @@ describe('Identity', function () { eq(a.get()(), result); }); - it('tests contramap for returning a value of the same Functor', function () { + it('tests contramap for returning a value of the same Functor', function() { const a = Identity.of(identity); const b = a.contramap(identity); @@ -314,40 +313,40 @@ describe('Identity', function () { }); }); - describe('Chain', function () { - it('tests for an Apply spec', function () { + describe('Chain', function() { + it('tests for an Apply spec', function() { const a = Identity.of(1); eq(isFunction(a[fl.ap]), true); eq(isFunction(a.constructor[fl.of]), true); }); - it('tests for associativity', function () { + it('tests for associativity', function() { chain.associativity(Identity)(eq)(1); }); - it('tests the only argument to be a function', function () { + it('tests the only argument to be a function', function() { const a = Identity.of(1); const fn = val => Identity.of(val + 1); eq(a.chain(fn).get(), 2); }); - it('tests the only argument to be a non-function', function () { + it('tests the only argument to be a non-function', function() { const a = Identity.of(1); const nonFn = null; chai.assert.throws(() => a.chain(nonFn), TypeError); }); - it('tests if the only argument is a function returning the value of the same Chain', function () { + it('tests if the only argument is a function returning the value of the same Chain', function() { const a = Identity.of(1); const fn = val => Identity.of(val + 1); eq(a.chain(fn) instanceof Identity, true); }); - it('tests if the only argument is a function returning the value of different Chain', function () { + it('tests if the only argument is a function returning the value of different Chain', function() { const a = Identity.of(1); const fn = val => val + 1; @@ -356,56 +355,56 @@ describe('Identity', function () { }); }); - describe('Monad', function () { - it('test for Applicative spec', function () { + describe('Monad', function() { + it('test for Applicative spec', function() { const a = Identity.of(1); eq(isFunction(Identity[fl.of]), true); eq(isFunction(a.constructor[fl.of]), true); }); - it('test for Chain spec', function () { + it('test for Chain spec', function() { const a = Identity.of(1); eq(isFunction(a[fl.chain]), true); }); - it('tests for leftIdentity', function () { + it('tests for leftIdentity', function() { monad.leftIdentity(Identity)(eq)(Identity.of)(1); }); - it('tests for rightIdentity', function () { + it('tests for rightIdentity', function() { monad.rightIdentity(Identity)(eq)(1); }); }); - describe('Ord', function () { - it('tests for Setoid spec', function () { + describe('Ord', function() { + it('tests for Setoid spec', function() { const a = Identity.of(1); eq(isFunction(a[fl.equals]), true); }); - it('tests for totality', function () { + it('tests for totality', function() { ord.totality(eq)(Identity.of(1))(Identity.of(2)); }); - it('tests for antisymetry', function () { + it('tests for antisymetry', function() { ord.antisymmetry(eq)(Identity.of(1))(Identity.of(1)); }); - it('tests for transitivity', function () { + it('tests for transitivity', function() { ord.transitivity(eq)(Identity.of(1))(Identity.of(2))(Identity.of(3)); }); - it('tests for value of the same Ord', function () { + it('tests for value of the same Ord', function() { const a = Identity.of(1); const b = Identity.of(2); eq(a.lte(b), true); }); - it('tests for value of different Ord', function () { + it('tests for value of different Ord', function() { const a = Identity.of(1); const b = Identity.of(2); @@ -414,7 +413,7 @@ describe('Identity', function () { eq(a.lte(b), false); }); - it('tests for returning a boolean', function () { + it('tests for returning a boolean', function() { const a = Identity.of(1); const b = Identity.of(2); @@ -423,28 +422,28 @@ describe('Identity', function () { }); }); - describe('Monoid*', function () { - it('tests for an Semigroup spec', function () { + describe('Monoid*', function() { + it('tests for an Semigroup spec', function() { const i = Identity.of('string').empty(); eq(isFunction(i[fl.concat]), true); }); - it('tests for right identity', function () { + it('tests for right identity', function() { const a = Identity.of('string'); const i = a.empty(); eq(a.concat(i), a); }); - it('tests for left identity', function () { + it('tests for left identity', function() { const a = Identity.of('string'); const i = a.empty(); eq(i.concat(a), a); }); - it('tests empty for returning a value of the same Monoid', function () { + it('tests empty for returning a value of the same Monoid', function() { const a = Identity.of('string'); const i = a.empty(); @@ -452,8 +451,12 @@ describe('Identity', function () { eq(i instanceof Identity, true); }); - it("tests delegating to inner's type empty method", function () { - const Type = { empty() { return 0 } }; + it("tests delegating to inner's type empty method", function() { + const Type = { + empty() { + return 0; + }, + }; const a = Identity.of(Type); const i = a.empty(); diff --git a/test/flattenPath.js b/test/flattenPath.js index f7f0f4bc06..b3ff957c98 100644 --- a/test/flattenPath.js +++ b/test/flattenPath.js @@ -1,12 +1,11 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('flattenPath', function () { +describe('flattenPath', function() { let path; let obj; - beforeEach(function () { + beforeEach(function() { path = ['b1', 'b2']; obj = { a: 1, @@ -14,24 +13,30 @@ describe('flattenPath', function () { }; }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.flattenPath([], {}), {}); eq(RA.flattenPath([])({}), {}); }); - context('when path leads to non object', function () { - specify('should return object with identical structure as provided object', function () { - obj = { - a: 1, - b1: { b2: 999 }, - }; - eq(RA.flattenPath(path, obj), obj); - }); + context('when path leads to non object', function() { + specify( + 'should return object with identical structure as provided object', + function() { + obj = { + a: 1, + b1: { b2: 999 }, + }; + eq(RA.flattenPath(path, obj), obj); + } + ); }); - context("when path doesn't exist", function () { - specify('should return object with identical structure as provided object', function () { - eq(RA.flattenPath(['does', 'not', 'exist'], obj), obj); - }); + context("when path doesn't exist", function() { + specify( + 'should return object with identical structure as provided object', + function() { + eq(RA.flattenPath(['does', 'not', 'exist'], obj), obj); + } + ); }); }); diff --git a/test/flattenProp.js b/test/flattenProp.js index a38aca3a09..847be0bb2a 100644 --- a/test/flattenProp.js +++ b/test/flattenProp.js @@ -1,12 +1,11 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('flattenProp', function () { +describe('flattenProp', function() { let prop; let obj; - beforeEach(function () { + beforeEach(function() { prop = 'b'; obj = { a: 1, @@ -14,29 +13,35 @@ describe('flattenProp', function () { }; }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.flattenProp('prop', {}), {}); eq(RA.flattenProp('prop')({}), {}); }); - context("when prop doesn't exist", function () { - specify('should return object with identical structure as provided object', function () { - eq(RA.flattenProp('not_exist', obj), obj); - }); + context("when prop doesn't exist", function() { + specify( + 'should return object with identical structure as provided object', + function() { + eq(RA.flattenProp('not_exist', obj), obj); + } + ); }); - context('when prop leads to non object', function () { - specify('should return object with identical structure as provided object', function () { - obj = { - a: 1, - b: 999, - }; - eq(RA.flattenProp(prop, obj), obj); - }); + context('when prop leads to non object', function() { + specify( + 'should return object with identical structure as provided object', + function() { + obj = { + a: 1, + b: 999, + }; + eq(RA.flattenProp(prop, obj), obj); + } + ); }); - context('when prop leads to object with same prop name', function () { - specify('should override existing props on provided object', function () { + context('when prop leads to object with same prop name', function() { + specify('should override existing props on provided object', function() { obj = { a: 1, b: { b: 999, c: 3, d: 4 }, @@ -52,7 +57,7 @@ describe('flattenProp', function () { }); }); - it('should return object with flattened prop', function () { + it('should return object with flattened prop', function() { const expected = { a: 1, c: 3, diff --git a/test/hasPath.js b/test/hasPath.js index 52cf4096ff..438b2b7d11 100644 --- a/test/hasPath.js +++ b/test/hasPath.js @@ -1,15 +1,14 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('hasPath', function () { - it('tests for paths in objects', function () { +describe('hasPath', function() { + it('tests for paths in objects', function() { eq(RA.hasPath(['a', 'b'], { a: { b: 1 } }), true); eq(RA.hasPath(['a', 'b', 'c'], { a: { b: 1 } }), false); - eq(RA.hasPath(['a', 'b'], { a: { } }), false); + eq(RA.hasPath(['a', 'b'], { a: {} }), false); }); - it('tests for paths in arrays', function () { + it('tests for paths in arrays', function() { eq(RA.hasPath([0], [1, 2]), true); eq(RA.hasPath([2], [1, 2]), false); @@ -17,16 +16,16 @@ describe('hasPath', function () { eq(RA.hasPath(['2'], [1, 2]), false); }); - it('tests empty path', function () { - eq(RA.hasPath([], { a: { } }), false); + it('tests empty path', function() { + eq(RA.hasPath([], { a: {} }), false); }); - it('tests paths on non-objects', function () { + it('tests paths on non-objects', function() { eq(RA.hasPath(['a', 'b'], undefined), false); eq(RA.hasPath(['a', 'b'], null), false); }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.hasPath(['a', 'b'])({ a: { b: 1 } }), true); }); }); diff --git a/test/internal/ap.js b/test/internal/ap.js index c8230c73dd..3fc79bb52d 100644 --- a/test/internal/ap.js +++ b/test/internal/ap.js @@ -4,20 +4,19 @@ import eq from '../shared/eq'; import _ap from '../../src/internal/ap'; import Identity from '../../src/fantasy-land/Identity'; - -describe('ap', function () { +describe('ap', function() { const m1 = Identity.of(1); const m2 = Identity.of(2).map(add); - it('tests new fantasyland spec compatibility', function () { + it('tests new fantasyland spec compatibility', function() { eq(_ap(m1, m2), Identity.of(3)); }); - it('tests old fantasyland spec compatibility', function () { + it('tests old fantasyland spec compatibility', function() { eq(_ap(m2, m1), Identity.of(3)); }); - it('tests for non Apply spec', function () { + it('tests for non Apply spec', function() { eq(_ap([multiply(2), add(3)], [1, 2, 3]), [2, 4, 6, 4, 5, 6]); }); }); diff --git a/test/isArray.js b/test/isArray.js index c12aaa1741..bdbd1571c6 100644 --- a/test/isArray.js +++ b/test/isArray.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isArray', function () { - it('tests a value for `Array`', function () { +describe('isArray', function() { + it('tests a value for `Array`', function() { eq(RA.isArray([]), true); eq(RA.isArray([1]), true); eq(RA.isArray(new Array()), true); diff --git a/test/isArrayLike.js b/test/isArrayLike.js index 20ca097301..79d5dbe68d 100644 --- a/test/isArrayLike.js +++ b/test/isArrayLike.js @@ -1,15 +1,14 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isArrayLike', function () { - it('is true for Arrays', function () { +describe('isArrayLike', function() { + it('is true for Arrays', function() { eq(RA.isArrayLike([]), true); eq(RA.isArrayLike([1, 2, 3, 4]), true); eq(RA.isArrayLike([null]), true); }); - it('is true for arguments', function () { + it('is true for arguments', function() { function testingFn() { return RA.isArrayLike(arguments); } @@ -18,12 +17,12 @@ describe('isArrayLike', function () { eq(testingFn(null), true); }); - it('is false for Strings', function () { + it('is false for Strings', function() { eq(RA.isArrayLike(''), false); eq(RA.isArrayLike('abcdefg'), false); }); - it('is true for arbitrary objects with numeric length, if extreme indices are defined', function () { + it('is true for arbitrary objects with numeric length, if extreme indices are defined', function() { const obj1 = { length: 0 }; const obj2 = { 0: 'something', length: 0 }; const obj3 = { 0: void 0, length: 0 }; @@ -41,12 +40,12 @@ describe('isArrayLike', function () { eq(RA.isArrayLike(obj7), false); }); - it('is false for everything else', function () { + it('is false for everything else', function() { eq(RA.isArrayLike(undefined), false); eq(RA.isArrayLike(1), false); eq(RA.isArrayLike({}), false); eq(RA.isArrayLike(false), false); - eq(RA.isArrayLike(function () {}), false); + eq(RA.isArrayLike(function() {}), false); }); }); diff --git a/test/isAsyncFunction.js b/test/isAsyncFunction.js index 98a17a392d..c106be6d55 100644 --- a/test/isAsyncFunction.js +++ b/test/isAsyncFunction.js @@ -4,9 +4,8 @@ import Symbol from './shared/Symbol'; import args from './shared/arguments'; import asyncFunc from './shared/asyncFunc'; - -describe('isAsyncFunction', function () { - it('tests a value for `Async Function`', function () { +describe('isAsyncFunction', function() { + it('tests a value for `Async Function`', function() { eq(RA.isAsyncFunction(asyncFunc), typeof asyncFunc === 'function'); eq(RA.isAsyncFunction(args), false); eq(RA.isAsyncFunction([1, 2, 3]), false); diff --git a/test/isBoolean.js b/test/isBoolean.js index 8030e0b074..f4ae80ed64 100644 --- a/test/isBoolean.js +++ b/test/isBoolean.js @@ -3,9 +3,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; import Symbol from './shared/Symbol'; - -describe('isBoolean', function () { - it('tests a value for `Boolean`', function () { +describe('isBoolean', function() { + it('tests a value for `Boolean`', function() { eq(RA.isBoolean(true), true); eq(RA.isBoolean(false), true); eq(RA.isBoolean(Object(true)), true); diff --git a/test/isDate.js b/test/isDate.js index d58fb348a5..366d930777 100644 --- a/test/isDate.js +++ b/test/isDate.js @@ -3,9 +3,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isDate', function () { - it('tests a value for `Date`', function () { +describe('isDate', function() { + it('tests a value for `Date`', function() { eq(RA.isDate(new Date()), true); eq(RA.isDate(Date.now()), false); diff --git a/test/isEmptyArray.js b/test/isEmptyArray.js index 63da0157e8..086a43de39 100644 --- a/test/isEmptyArray.js +++ b/test/isEmptyArray.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isEmptyArray', function () { - it('tests a value to be an empty `Array`', function () { +describe('isEmptyArray', function() { + it('tests a value to be an empty `Array`', function() { eq(RA.isEmptyArray([]), true); eq(RA.isEmptyArray(new Array()), true); eq(RA.isEmptyArray(Array.prototype), true); diff --git a/test/isEmptyString.js b/test/isEmptyString.js index 0d0519ab07..a49aa17580 100644 --- a/test/isEmptyString.js +++ b/test/isEmptyString.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isEmptyString', function () { - it('tests a value to be an empty `String`', function () { +describe('isEmptyString', function() { + it('tests a value to be an empty `String`', function() { eq(RA.isEmptyString(''), true); eq(RA.isEmptyString('42'), false); diff --git a/test/isEven.js b/test/isEven.js index 521177de04..b26f1dcfd9 100644 --- a/test/isEven.js +++ b/test/isEven.js @@ -5,9 +5,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isEven', function () { - it('tests a value for even integer `Number`', function () { +describe('isEven', function() { + it('tests a value for even integer `Number`', function() { eq(RA.isEven(0), true); eq(RA.isEven(4), true); eq(RA.isEven(Object(4)), false); diff --git a/test/isFalsy.js b/test/isFalsy.js index 21c58b7ae3..60c61df547 100644 --- a/test/isFalsy.js +++ b/test/isFalsy.js @@ -3,9 +3,8 @@ import eq from './shared/eq'; import Symbol from './shared/Symbol'; import args from './shared/arguments'; - -describe('isFalsy', function () { - it('tests a value for `falsy`', function () { +describe('isFalsy', function() { + it('tests a value for `falsy`', function() { eq(RA.isFalsy(false), true); eq(RA.isFalsy(0), true); eq(RA.isFalsy(-0), true); diff --git a/test/isFinite.js b/test/isFinite.js index 97287e6693..ee46c52271 100644 --- a/test/isFinite.js +++ b/test/isFinite.js @@ -2,9 +2,8 @@ import * as RA from '../src/index'; import polyfill from '../src/internal/polyfills/Number.isFinite'; import eq from './shared/eq'; - -describe('isFinite', function () { - it('tests a value for finite `Number`', function () { +describe('isFinite', function() { + it('tests a value for finite `Number`', function() { eq(RA.isFinite(Infinity), false); eq(RA.isFinite(NaN), false); eq(RA.isFinite(-Infinity), false); @@ -22,7 +21,7 @@ describe('isFinite', function () { eq(RA.isFinite(null), false); }); - it('tests polyfill for finite `Number', function () { + it('tests polyfill for finite `Number', function() { eq(polyfill(Infinity), false); eq(polyfill(NaN), false); eq(polyfill(-Infinity), false); diff --git a/test/isFloat.js b/test/isFloat.js index 395ebd9bfe..2ea0e5267d 100644 --- a/test/isFloat.js +++ b/test/isFloat.js @@ -3,19 +3,20 @@ import MAX_SAFE_INTEGER from '../src/internal/polyfills/Number.MAX_SAFE_INTEGER' import MIN_SAFE_INTEGER from '../src/internal/polyfills/Number.MIN_SAFE_INTEGER'; import eq from './shared/eq'; - -describe('isFloat', function () { - it('tests a value for `float`', function () { +describe('isFloat', function() { + it('tests a value for `float`', function() { eq(RA.isFloat(0), false); eq(RA.isFloat(1), false); eq(RA.isFloat(-100000), false); eq(RA.isFloat(MAX_SAFE_INTEGER), false); eq(RA.isFloat(MIN_SAFE_INTEGER), false); + // prettier-ignore eq(RA.isFloat(5e+0), false); eq(RA.isFloat(0.1), true); eq(RA.isFloat(Math.PI), true); - eq(RA.isFloat(5.56789e+0), true); + // prettier-ignore + eq(RA.isFloat(5.56789+0), true); eq(RA.isFloat(NaN), false); eq(RA.isFloat(Infinity), false); diff --git a/test/isFunction.js b/test/isFunction.js index b9ca2bfe02..07d920178a 100644 --- a/test/isFunction.js +++ b/test/isFunction.js @@ -5,14 +5,13 @@ import args from './shared/arguments'; import genFunc from './shared/genFunc'; import asyncFunc from './shared/asyncFunc'; - -describe('isFunction', function () { - it('tests a value for `Function`', function () { +describe('isFunction', function() { + it('tests a value for `Function`', function() { eq(RA.isFunction(genFunc), typeof genFunc === 'function'); eq(RA.isFunction(asyncFunc), typeof asyncFunc === 'function'); eq(RA.isFunction(Symbol), typeof Symbol === 'function'); eq(RA.isFunction(() => {}), true); - eq(RA.isFunction(function () {}), true); + eq(RA.isFunction(function() {}), true); eq(RA.isFunction(Array.prototype.slice), true); eq(RA.isFunction(args), false); eq(RA.isFunction([1, 2, 3]), false); diff --git a/test/isGeneratorFunction.js b/test/isGeneratorFunction.js index 8c6dabed53..a1166cfb15 100644 --- a/test/isGeneratorFunction.js +++ b/test/isGeneratorFunction.js @@ -4,9 +4,8 @@ import Symbol from './shared/Symbol'; import args from './shared/arguments'; import genFunc from './shared/genFunc'; - -describe('isGeneratorFunction', function () { - it('tests a value for `Generator Function`', function () { +describe('isGeneratorFunction', function() { + it('tests a value for `Generator Function`', function() { eq(RA.isGeneratorFunction(genFunc), typeof genFunc === 'function'); eq(RA.isGeneratorFunction(args), false); eq(RA.isGeneratorFunction([1, 2, 3]), false); diff --git a/test/isInteger.js b/test/isInteger.js index 4877d4c529..c0d600ca0d 100644 --- a/test/isInteger.js +++ b/test/isInteger.js @@ -4,19 +4,18 @@ import MIN_SAFE_INTEGER from '../src/internal/polyfills/Number.MIN_SAFE_INTEGER' import eq from './shared/eq'; import polyfill from '../src/internal/polyfills/Number.isInteger'; - -describe('isInteger', function () { - it('tests a value for `integer`', function () { +describe('isInteger', function() { + it('tests a value for `integer`', function() { eq(RA.isInteger(0), true); eq(RA.isInteger(1), true); eq(RA.isInteger(-100000), true); eq(RA.isInteger(MAX_SAFE_INTEGER), true); eq(RA.isInteger(MIN_SAFE_INTEGER), true); - eq(RA.isInteger(5e+0), true); + eq(RA.isInteger(5), true); eq(RA.isInteger(0.1), false); eq(RA.isInteger(Math.PI), false); - eq(RA.isInteger(5.56789e+0), false); + eq(RA.isInteger(5.56789), false); eq(RA.isInteger(NaN), false); eq(RA.isInteger(Infinity), false); @@ -27,7 +26,7 @@ describe('isInteger', function () { eq(RA.isInteger([1]), false); }); - it('tests polyfill for `integer', function () { + it('tests polyfill for `integer', function() { eq(polyfill(0), true); eq(polyfill(1), true); eq(polyfill(-100000), true); diff --git a/test/isNaN.js b/test/isNaN.js index e3706274a0..606e1c940a 100644 --- a/test/isNaN.js +++ b/test/isNaN.js @@ -2,9 +2,8 @@ import * as RA from '../src/index'; import polyfill from '../src/internal/polyfills/Number.isNaN'; import eq from './shared/eq'; - -describe('isNaN', function () { - it('tests a value for `NaN`', function () { +describe('isNaN', function() { + it('tests a value for `NaN`', function() { eq(RA.isNaN(NaN), true); eq(RA.isNaN(Number.NaN), true); eq(RA.isNaN(0 / 0), true); @@ -25,7 +24,7 @@ describe('isNaN', function () { eq(RA.isNaN(' '), false); }); - it('tests polyfill for `NaN', function () { + it('tests polyfill for `NaN', function() { eq(polyfill(NaN), true); eq(polyfill(Number.NaN), true); eq(polyfill(0 / 0), true); diff --git a/test/isNegative.js b/test/isNegative.js index c1b6e38aa9..c7f5e0c641 100644 --- a/test/isNegative.js +++ b/test/isNegative.js @@ -5,9 +5,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isNegative', function () { - it('tests a value for negative `Number`', function () { +describe('isNegative', function() { + it('tests a value for negative `Number`', function() { eq(RA.isNegative(0), false); eq(RA.isNegative(-0.1), true); eq(RA.isNegative(Object(0)), false); diff --git a/test/isNilOrEmpty.js b/test/isNilOrEmpty.js index 9ab4cc81a8..f410500ce3 100644 --- a/test/isNilOrEmpty.js +++ b/test/isNilOrEmpty.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isNilOrEmpty', function () { - it('tests a value for `null` or `undefined`', function () { +describe('isNilOrEmpty', function() { + it('tests a value for `null` or `undefined`', function() { eq(RA.isNilOrEmpty(void 0), true); eq(RA.isNilOrEmpty(null), true); eq(RA.isNilOrEmpty([]), true); @@ -12,35 +11,49 @@ describe('isNilOrEmpty', function () { eq(RA.isNilOrEmpty(''), true); }); - it('returns true for null', function () { + it('returns true for null', function() { eq(RA.isNilOrEmpty(null), true); }); - it('returns true for undefined', function () { + it('returns true for undefined', function() { eq(RA.isNilOrEmpty(undefined), true); }); - it('returns true for empty string', function () { + it('returns true for empty string', function() { eq(RA.isNilOrEmpty(''), true); eq(RA.isNilOrEmpty(' '), false); }); - it('returns true for empty array', function () { + it('returns true for empty array', function() { eq(RA.isNilOrEmpty([]), true); eq(RA.isNilOrEmpty([[]]), false); }); - it('returns true for empty object', function () { + it('returns true for empty object', function() { eq(RA.isNilOrEmpty({}), true); eq(RA.isNilOrEmpty({ x: 0 }), false); }); - it('returns true for empty arguments object', function () { - eq(RA.isNilOrEmpty((function () { return arguments })()), true); - eq(RA.isNilOrEmpty((function () { return arguments })(0)), false); - }); - - it('returns false for every other value', function () { + it('returns true for empty arguments object', function() { + eq( + RA.isNilOrEmpty( + (function() { + return arguments; + })() + ), + true + ); + eq( + RA.isNilOrEmpty( + (function() { + return arguments; + })(0) + ), + false + ); + }); + + it('returns false for every other value', function() { eq(RA.isNilOrEmpty(0), false); eq(RA.isNilOrEmpty(NaN), false); eq(RA.isNilOrEmpty(['']), false); diff --git a/test/isNonEmptyArray.js b/test/isNonEmptyArray.js index f29ab6d294..a106d9ee68 100644 --- a/test/isNonEmptyArray.js +++ b/test/isNonEmptyArray.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isNonEmptyArray', function () { - it('tests a value to be a non empty `Array`', function () { +describe('isNonEmptyArray', function() { + it('tests a value to be a non empty `Array`', function() { eq(RA.isNonEmptyArray([42]), true); eq(RA.isNonEmptyArray(new Array('content')), true); diff --git a/test/isNonEmptyString.js b/test/isNonEmptyString.js index 19cd979f48..ffd498f04f 100644 --- a/test/isNonEmptyString.js +++ b/test/isNonEmptyString.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isNonEmptyString', function () { - it('tests a value to be an empty `String`', function () { +describe('isNonEmptyString', function() { + it('tests a value to be an empty `String`', function() { eq(RA.isNonEmptyString('42'), true); eq(RA.isNonEmptyString(''), false); diff --git a/test/isNotArray.js b/test/isNotArray.js index c18ff1cdd7..a8f5650029 100644 --- a/test/isNotArray.js +++ b/test/isNotArray.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isNotArray', function () { - it('tests a value for complement of `Array`', function () { +describe('isNotArray', function() { + it('tests a value for complement of `Array`', function() { eq(RA.isNotArray([]), false); eq(RA.isNotArray([1]), false); eq(RA.isNotArray(new Array()), false); diff --git a/test/isNotArrayLike.js b/test/isNotArrayLike.js index af5684f6b0..1e8a3a665d 100644 --- a/test/isNotArrayLike.js +++ b/test/isNotArrayLike.js @@ -1,15 +1,14 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isArrayLike', function () { - it('is false for Arrays', function () { +describe('isArrayLike', function() { + it('is false for Arrays', function() { eq(RA.isNotArrayLike([]), false); eq(RA.isNotArrayLike([1, 2, 3, 4]), false); eq(RA.isNotArrayLike([null]), false); }); - it('is false for arguments', function () { + it('is false for arguments', function() { function testingFn() { return RA.isNotArrayLike(arguments); } @@ -18,12 +17,12 @@ describe('isArrayLike', function () { eq(testingFn(null), false); }); - it('is true for Strings', function () { + it('is true for Strings', function() { eq(RA.isNotArrayLike(''), true); eq(RA.isNotArrayLike('abcdefg'), true); }); - it('is false for arbitrary objects with numeric length, if extreme indices are defined', function () { + it('is false for arbitrary objects with numeric length, if extreme indices are defined', function() { const obj1 = { length: 0 }; const obj2 = { 0: 'something', length: 0 }; const obj3 = { 0: void 0, length: 0 }; @@ -38,11 +37,11 @@ describe('isArrayLike', function () { eq(RA.isNotArrayLike(obj6), true); }); - it('is true for everything else', function () { + it('is true for everything else', function() { eq(RA.isNotArrayLike(undefined), true); eq(RA.isNotArrayLike(1), true); eq(RA.isNotArrayLike({}), true); eq(RA.isNotArrayLike(false), true); - eq(RA.isNotArrayLike(function () {}), true); + eq(RA.isNotArrayLike(function() {}), true); }); }); diff --git a/test/isNotAsyncFunction.js b/test/isNotAsyncFunction.js index 5bcf009423..84f92428f5 100644 --- a/test/isNotAsyncFunction.js +++ b/test/isNotAsyncFunction.js @@ -4,9 +4,8 @@ import Symbol from './shared/Symbol'; import args from './shared/arguments'; import asyncFunc from './shared/asyncFunc'; - -describe('isNotAsyncFunction', function () { - it('tests a value for complement of `Async Function`', function () { +describe('isNotAsyncFunction', function() { + it('tests a value for complement of `Async Function`', function() { eq(RA.isNotAsyncFunction(asyncFunc), typeof asyncFunc !== 'function'); eq(RA.isNotAsyncFunction(args), true); eq(RA.isNotAsyncFunction([1, 2, 3]), true); diff --git a/test/isNotBoolean.js b/test/isNotBoolean.js index 2f239fedfc..ce1e965415 100644 --- a/test/isNotBoolean.js +++ b/test/isNotBoolean.js @@ -3,9 +3,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; import Symbol from './shared/Symbol'; - -describe('isNotBoolean', function () { - it('tests a value for complement of `Boolean`', function () { +describe('isNotBoolean', function() { + it('tests a value for complement of `Boolean`', function() { eq(RA.isNotBoolean(true), false); eq(RA.isNotBoolean(false), false); eq(RA.isNotBoolean(Object(true)), false); diff --git a/test/isNotDate.js b/test/isNotDate.js index a738a82c0d..db232a7414 100644 --- a/test/isNotDate.js +++ b/test/isNotDate.js @@ -3,9 +3,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isNotDate', function () { - it('tests a value for complement of `Date`', function () { +describe('isNotDate', function() { + it('tests a value for complement of `Date`', function() { eq(RA.isNotDate(new Date()), false); eq(RA.isNotDate(Date.now()), true); diff --git a/test/isNotEmpty.js b/test/isNotEmpty.js index 7d4ae7b663..d3f3b27d61 100644 --- a/test/isNotEmpty.js +++ b/test/isNotEmpty.js @@ -1,37 +1,50 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isNotEmpty', function () { - it('returns true for null', function () { +describe('isNotEmpty', function() { + it('returns true for null', function() { eq(RA.isNotEmpty(null), true); }); - it('returns true for undefined', function () { + it('returns true for undefined', function() { eq(RA.isNotEmpty(undefined), true); }); - it('returns false for empty string', function () { + it('returns false for empty string', function() { eq(RA.isNotEmpty(''), false); eq(RA.isNotEmpty(' '), true); }); - it('returns false for empty array', function () { + it('returns false for empty array', function() { eq(RA.isNotEmpty([]), false); eq(RA.isNotEmpty([[]]), true); }); - it('returns false for empty object', function () { + it('returns false for empty object', function() { eq(RA.isNotEmpty({}), false); eq(RA.isNotEmpty({ x: 0 }), true); }); - it('returns false for empty arguments object', function () { - eq(RA.isNotEmpty((function () { return arguments })()), false); - eq(RA.isNotEmpty((function () { return arguments })(0)), true); + it('returns false for empty arguments object', function() { + eq( + RA.isNotEmpty( + (function() { + return arguments; + })() + ), + false + ); + eq( + RA.isNotEmpty( + (function() { + return arguments; + })(0) + ), + true + ); }); - it('returns true for every other value', function () { + it('returns true for every other value', function() { eq(RA.isNotEmpty(0), true); eq(RA.isNotEmpty(NaN), true); eq(RA.isNotEmpty(['']), true); diff --git a/test/isNotFinite.js b/test/isNotFinite.js index 2e83709196..6a30740f6e 100644 --- a/test/isNotFinite.js +++ b/test/isNotFinite.js @@ -4,9 +4,8 @@ import * as RA from '../src/index'; import polyfill from '../src/internal/polyfills/Number.isFinite'; import eq from './shared/eq'; - -describe('isNotFinite', function () { - it('tests a value for complement of finite `Number`', function () { +describe('isNotFinite', function() { + it('tests a value for complement of finite `Number`', function() { eq(RA.isNotFinite(Infinity), true); eq(RA.isNotFinite(NaN), true); eq(RA.isNotFinite(-Infinity), true); @@ -21,7 +20,7 @@ describe('isNotFinite', function () { eq(RA.isNotFinite(null), true); }); - it('tests polyfill for complement of finite `Number', function () { + it('tests polyfill for complement of finite `Number', function() { const polyfillC = complement(polyfill); eq(polyfillC(Infinity), true); diff --git a/test/isNotFloat.js b/test/isNotFloat.js index 40fde37732..d2ad614ff1 100644 --- a/test/isNotFloat.js +++ b/test/isNotFloat.js @@ -3,19 +3,20 @@ import MAX_SAFE_INTEGER from '../src/internal/polyfills/Number.MAX_SAFE_INTEGER' import MIN_SAFE_INTEGER from '../src/internal/polyfills/Number.MIN_SAFE_INTEGER'; import eq from './shared/eq'; - -describe('isNotFloat', function () { - it('tests a value for complement of a `float`', function () { +describe('isNotFloat', function() { + it('tests a value for complement of a `float`', function() { eq(RA.isNotFloat(0), true); eq(RA.isNotFloat(1), true); eq(RA.isNotFloat(-100000), true); eq(RA.isNotFloat(MAX_SAFE_INTEGER), true); eq(RA.isNotFloat(MIN_SAFE_INTEGER), true); + // prettier-ignore eq(RA.isNotFloat(5e+0), true); eq(RA.isNotFloat(0.1), false); eq(RA.isNotFloat(Math.PI), false); - eq(RA.isNotFloat(5.56789e+0), false); + // prettier-ignore + eq(RA.isNotFloat(5.56789+0), false); eq(RA.isNotFloat(NaN), true); eq(RA.isNotFloat(Infinity), true); diff --git a/test/isNotFunction.js b/test/isNotFunction.js index 1520fdf17b..b34302562c 100644 --- a/test/isNotFunction.js +++ b/test/isNotFunction.js @@ -5,14 +5,13 @@ import args from './shared/arguments'; import genFunc from './shared/genFunc'; import asyncFunc from './shared/asyncFunc'; - -describe('isNotFunction', function () { - it('tests a value for complement of `Function`', function () { +describe('isNotFunction', function() { + it('tests a value for complement of `Function`', function() { eq(RA.isNotFunction(genFunc), typeof genFunc !== 'function'); eq(RA.isNotFunction(asyncFunc), typeof asyncFunc !== 'function'); eq(RA.isNotFunction(Symbol), typeof Symbol !== 'function'); eq(RA.isNotFunction(() => {}), false); - eq(RA.isNotFunction(function () {}), false); + eq(RA.isNotFunction(function() {}), false); eq(RA.isNotFunction(Array.prototype.slice), false); eq(RA.isNotFunction(args), true); eq(RA.isNotFunction([1, 2, 3]), true); diff --git a/test/isNotGeneratorFunction.js b/test/isNotGeneratorFunction.js index 4c4ebdb18d..6ba2025fe7 100644 --- a/test/isNotGeneratorFunction.js +++ b/test/isNotGeneratorFunction.js @@ -4,9 +4,8 @@ import Symbol from './shared/Symbol'; import args from './shared/arguments'; import genFunc from './shared/genFunc'; - -describe('isNotGeneratorFunction', function () { - it('tests a value for complement of `Generator Function`', function () { +describe('isNotGeneratorFunction', function() { + it('tests a value for complement of `Generator Function`', function() { eq(RA.isNotGeneratorFunction(genFunc), typeof genFunc !== 'function'); eq(RA.isNotGeneratorFunction(args), true); eq(RA.isNotGeneratorFunction([1, 2, 3]), true); diff --git a/test/isNotInteger.js b/test/isNotInteger.js index 1af8e17c7d..4137adf60f 100644 --- a/test/isNotInteger.js +++ b/test/isNotInteger.js @@ -6,9 +6,8 @@ import MIN_SAFE_INTEGER from '../src/internal/polyfills/Number.MIN_SAFE_INTEGER' import eq from './shared/eq'; import polyfill from '../src/internal/polyfills/Number.isInteger'; - -describe('isNotInteger', function () { - it('tests a value for complement of `integer`', function () { +describe('isNotInteger', function() { + it('tests a value for complement of `integer`', function() { eq(RA.isNotInteger(0), false); eq(RA.isNotInteger(1), false); eq(RA.isNotInteger(-100000), false); @@ -27,7 +26,7 @@ describe('isNotInteger', function () { eq(RA.isNotInteger([1]), true); }); - it('tests polyfill for complement of `integer', function () { + it('tests polyfill for complement of `integer', function() { const polyfillC = complement(polyfill); eq(polyfillC(0), false); diff --git a/test/isNotNaN.js b/test/isNotNaN.js index 26120890fa..3e93189b9f 100644 --- a/test/isNotNaN.js +++ b/test/isNotNaN.js @@ -4,9 +4,8 @@ import * as RA from '../src/index'; import polyfill from '../src/internal/polyfills/Number.isNaN'; import eq from './shared/eq'; - -describe('isNotNaN', function () { - it('tests a value for complement of `NaN`', function () { +describe('isNotNaN', function() { + it('tests a value for complement of `NaN`', function() { eq(RA.isNotNaN(NaN), false); eq(RA.isNotNaN(Number.NaN), false); eq(RA.isNotNaN(0 / 0), false); @@ -25,7 +24,7 @@ describe('isNotNaN', function () { eq(RA.isNotNaN(' '), true); }); - it('tests polyfill for complement of `NaN', function () { + it('tests polyfill for complement of `NaN', function() { const polyfillC = complement(polyfill); eq(polyfillC(NaN), false); diff --git a/test/isNotNil.js b/test/isNotNil.js index d886ce1f4f..7941497a87 100644 --- a/test/isNotNil.js +++ b/test/isNotNil.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isNotNil', function () { - it('tests a value for complement of `null` or `undefined`', function () { +describe('isNotNil', function() { + it('tests a value for complement of `null` or `undefined`', function() { eq(RA.isNotNil(void 0), false); eq(RA.isNotNil(null), false); eq(RA.isNotNil([]), true); diff --git a/test/isNotNull.js b/test/isNotNull.js index 7bcf5248e5..26d269abfc 100644 --- a/test/isNotNull.js +++ b/test/isNotNull.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isNotNull', function () { - it('tests a value for complement of `null`', function () { +describe('isNotNull', function() { + it('tests a value for complement of `null`', function() { eq(RA.isNotNull(void 0), true); eq(RA.isNotNull(null), false); eq(RA.isNotNull([]), true); diff --git a/test/isNotNumber.js b/test/isNotNumber.js index 48e971f068..0660a807b9 100644 --- a/test/isNotNumber.js +++ b/test/isNotNumber.js @@ -5,9 +5,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isNotNumber', function () { - it('tests a value for complement of `Number`', function () { +describe('isNotNumber', function() { + it('tests a value for complement of `Number`', function() { eq(RA.isNotNumber(0), false); eq(RA.isNotNumber(0.1), false); eq(RA.isNotNumber(Object(0)), false); diff --git a/test/isNotObj.js b/test/isNotObj.js index c07e861c06..ecf3986e49 100644 --- a/test/isNotObj.js +++ b/test/isNotObj.js @@ -3,9 +3,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isNotObj', function () { - it('tests a value for complement of language type of `Object`', function () { +describe('isNotObj', function() { + it('tests a value for complement of language type of `Object`', function() { eq(RA.isNotObj({}), false); eq(RA.isNotObj(Object(false)), false); eq(RA.isNotObj(Object.create(null)), false); @@ -27,8 +26,8 @@ describe('isNotObj', function () { }); }); -describe('isNotObject', function () { - it('tests an alias', function () { +describe('isNotObject', function() { + it('tests an alias', function() { eq(RA.isNotObj === RA.isNotObject, true); }); }); diff --git a/test/isNotObjLike.js b/test/isNotObjLike.js index 436dd82aa7..cafbeef40c 100644 --- a/test/isNotObjLike.js +++ b/test/isNotObjLike.js @@ -3,9 +3,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isNotObjLike', function () { - it('tests a value for non object-like interface', function () { +describe('isNotObjLike', function() { + it('tests a value for non object-like interface', function() { eq(RA.isNotObjLike({}), false); eq(RA.isNotObjLike(Object(false)), false); eq(RA.isNotObjLike(args), false); @@ -26,8 +25,8 @@ describe('isNotObjLike', function () { }); }); -describe('isNotObjectLike', function () { - it('tests an alias', function () { +describe('isNotObjectLike', function() { + it('tests an alias', function() { eq(RA.isNotObjLike === RA.isNotObjectLike, true); }); }); diff --git a/test/isNotPair.js b/test/isNotPair.js index 4fb649e04d..8ba70780fb 100644 --- a/test/isNotPair.js +++ b/test/isNotPair.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isNotPair', function () { - it('tests a value for complement of pair', function () { +describe('isNotPair', function() { + it('tests a value for complement of pair', function() { eq(RA.isNotPair([]), true); eq(RA.isNotPair([0]), true); eq(RA.isNotPair([0, 1]), false); diff --git a/test/isNotPlainObj.js b/test/isNotPlainObj.js index 4fa62d450d..f4cdd27608 100644 --- a/test/isNotPlainObj.js +++ b/test/isNotPlainObj.js @@ -4,15 +4,14 @@ import element from './shared/element'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - class Bar { constructor() { this.prop = 'value'; } } -describe('isNotPlainObj', function () { - it('tests a value for POJO', function () { +describe('isNotPlainObj', function() { + it('tests a value for POJO', function() { eq(RA.isNotPlainObj({}), false); eq(RA.isNotPlainObj({ prop: 'value' }), false); eq(RA.isNotPlainObj({ constructor: Bar }), false); @@ -20,7 +19,7 @@ describe('isNotPlainObj', function () { eq(RA.isNotPlainObj(['a', 'b', 'c']), true); }); - it('tests a value with prototype of null', function () { + it('tests a value with prototype of null', function() { eq(RA.isNotPlainObj(Object.create(null)), false); const object = Object.create(null); @@ -29,21 +28,21 @@ describe('isNotPlainObj', function () { eq(RA.isNotPlainObj(object), false); }); - it('tests a value with `valueOf` property', function () { + it('tests a value with `valueOf` property', function() { eq(RA.isNotPlainObj({ valueOf: 1 }), false); }); - it('test a value with custom prototype', function () { + it('test a value with custom prototype', function() { eq(RA.isNotPlainObj(Object.create({ a: 3 })), false); }); - it('test a value that is DOM element', function () { + it('test a value that is DOM element', function() { if (element) { eq(RA.isNotPlainObj(element), true); } }); - it('test a value for non-objects', function () { + it('test a value for non-objects', function() { eq(RA.isNotPlainObj(args), true); eq(RA.isNotPlainObj(Error), true); eq(RA.isNotPlainObj(Math), true); @@ -51,15 +50,15 @@ describe('isNotPlainObj', function () { eq(RA.isNotPlainObj('abc'), true); }); - it('test a value for Symbol', function () { + it('test a value for Symbol', function() { if (Symbol) { eq(RA.isNotPlainObj(Symbol.for('symbol')), true); } }); }); -describe('isNotPlainObject', function () { - it('tests an alias', function () { +describe('isNotPlainObject', function() { + it('tests an alias', function() { eq(RA.isNotPlainObj === RA.isNotPlainObject, true); }); }); diff --git a/test/isNotRegExp.js b/test/isNotRegExp.js index 6179e00c50..17b17f5627 100644 --- a/test/isNotRegExp.js +++ b/test/isNotRegExp.js @@ -3,9 +3,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isNotRegExp', function () { - it('tests a value for complement of `RegExp`', function () { +describe('isNotRegExp', function() { + it('tests a value for complement of `RegExp`', function() { eq(RA.isNotRegExp('a'), true); eq(RA.isNotRegExp(1), true); eq(RA.isNotRegExp([]), true); @@ -15,7 +14,7 @@ describe('isNotRegExp', function () { eq(RA.isNotRegExp(new Error()), true); eq(RA.isNotRegExp(new Date()), true); eq(RA.isNotRegExp(RA), true); - eq(RA.isNotRegExp(function () {}), true); + eq(RA.isNotRegExp(function() {}), true); eq(RA.isNotRegExp(Object(0)), true); eq(RA.isNotRegExp(Object('a')), true); eq(RA.isNotRegExp(args), true); diff --git a/test/isNotString.js b/test/isNotString.js index 7bdcb1d933..baa1991d71 100644 --- a/test/isNotString.js +++ b/test/isNotString.js @@ -3,9 +3,8 @@ import eq from './shared/eq'; import Symbol from './shared/Symbol'; import args from './shared/arguments'; - -describe('isNotString', function () { - it('tests a value for complement of `String`', function () { +describe('isNotString', function() { + it('tests a value for complement of `String`', function() { eq(RA.isNotString('abc'), false); eq(RA.isNotString(Object('abc')), false); diff --git a/test/isNotUndefined.js b/test/isNotUndefined.js index ef78336fec..98334d583b 100644 --- a/test/isNotUndefined.js +++ b/test/isNotUndefined.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isNotUndefined', function () { - it('tests a value for complement of `undefined`', function () { +describe('isNotUndefined', function() { + it('tests a value for complement of `undefined`', function() { eq(RA.isNotUndefined(void 0), false); eq(RA.isNotUndefined(undefined), false); eq(RA.isNotUndefined(null), true); diff --git a/test/isNotValidDate.js b/test/isNotValidDate.js index 956a8a4437..a5d22e2c56 100644 --- a/test/isNotValidDate.js +++ b/test/isNotValidDate.js @@ -3,9 +3,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isNotValidDate', function () { - it('tests a value for complement of valid `Date`', function () { +describe('isNotValidDate', function() { + it('tests a value for complement of valid `Date`', function() { eq(RA.isNotValidDate(new Date()), false); eq(RA.isNotValidDate(new Date('a')), true); @@ -30,8 +29,8 @@ describe('isNotValidDate', function () { }); }); -describe('isInvalidDate', function () { - it('tests an alias', function () { +describe('isInvalidDate', function() { + it('tests an alias', function() { eq(RA.isNotValidDate === RA.isInvalidDate, true); }); }); diff --git a/test/isNotValidNumber.js b/test/isNotValidNumber.js index dc1a5dee0c..8bbc6f0260 100644 --- a/test/isNotValidNumber.js +++ b/test/isNotValidNumber.js @@ -5,9 +5,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isNotValidNumber', function () { - it('tests a value for complement of valid `Number`', function () { +describe('isNotValidNumber', function() { + it('tests a value for complement of valid `Number`', function() { eq(RA.isNotValidNumber(0), false); eq(RA.isNotValidNumber(0.1), false); eq(RA.isNotValidNumber(-0.1), false); diff --git a/test/isNull.js b/test/isNull.js index bb4ec76d92..1b38aeec4b 100644 --- a/test/isNull.js +++ b/test/isNull.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isNull', function () { - it('tests a value for `null`', function () { +describe('isNull', function() { + it('tests a value for `null`', function() { eq(RA.isNull(void 0), false); eq(RA.isNull(null), true); eq(RA.isNull([]), false); diff --git a/test/isNumber.js b/test/isNumber.js index 6aa330d2f1..678f756bf1 100644 --- a/test/isNumber.js +++ b/test/isNumber.js @@ -5,9 +5,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isNumber', function () { - it('tests a value for `Number`', function () { +describe('isNumber', function() { + it('tests a value for `Number`', function() { eq(RA.isNumber(0), true); eq(RA.isNumber(0.1), true); eq(RA.isNumber(Object(0)), true); diff --git a/test/isObj.js b/test/isObj.js index 4716988a3e..b47fd4d5f2 100644 --- a/test/isObj.js +++ b/test/isObj.js @@ -3,9 +3,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isObj', function () { - it('tests a value for language type of `Object`', function () { +describe('isObj', function() { + it('tests a value for language type of `Object`', function() { eq(RA.isObj({}), true); eq(RA.isObj(Object(true)), true); eq(RA.isObj(Object.create(null)), true); @@ -27,8 +26,8 @@ describe('isObj', function () { }); }); -describe('isObject', function () { - it('tests an alias', function () { +describe('isObject', function() { + it('tests an alias', function() { eq(RA.isObj === RA.isObject, true); }); }); diff --git a/test/isObjLike.js b/test/isObjLike.js index 748e9e2ff5..35539dc56c 100644 --- a/test/isObjLike.js +++ b/test/isObjLike.js @@ -3,9 +3,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isObjLike', function () { - it('tests a value for object-like interface', function () { +describe('isObjLike', function() { + it('tests a value for object-like interface', function() { eq(RA.isObjLike({}), true); eq(RA.isObjLike(Object(true)), true); eq(RA.isObjLike(args), true); @@ -26,9 +25,8 @@ describe('isObjLike', function () { }); }); -describe('isObjectLike', function () { - it('tests an alias', function () { +describe('isObjectLike', function() { + it('tests an alias', function() { eq(RA.isObjLike === RA.isObjectLike, true); }); }); - diff --git a/test/isOdd.js b/test/isOdd.js index a92b1ca631..125b1a4e62 100644 --- a/test/isOdd.js +++ b/test/isOdd.js @@ -5,9 +5,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isOdd', function () { - it('tests a value for odd integer `Number`', function () { +describe('isOdd', function() { + it('tests a value for odd integer `Number`', function() { eq(RA.isOdd(0), false); eq(RA.isOdd(4), false); eq(RA.isOdd(Object(0)), false); diff --git a/test/isPair.js b/test/isPair.js index f5cf2da8b5..d0124ecd64 100644 --- a/test/isPair.js +++ b/test/isPair.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isPair', function () { - it('tests a value for pair', function () { +describe('isPair', function() { + it('tests a value for pair', function() { eq(RA.isPair([]), false); eq(RA.isPair([0]), false); eq(RA.isPair([0, 1]), true); diff --git a/test/isPlainObj.js b/test/isPlainObj.js index fc2bc7f68b..aff1c037ff 100644 --- a/test/isPlainObj.js +++ b/test/isPlainObj.js @@ -4,15 +4,14 @@ import element from './shared/element'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - class Bar { constructor() { this.prop = 'value'; } } -describe('isPlainObj', function () { - it('tests a value for POJO', function () { +describe('isPlainObj', function() { + it('tests a value for POJO', function() { eq(RA.isPlainObj({}), true); eq(RA.isPlainObj({ prop: 'value' }), true); eq(RA.isPlainObj({ constructor: Bar }), true); @@ -20,7 +19,7 @@ describe('isPlainObj', function () { eq(RA.isPlainObj(['a', 'b', 'c']), false); }); - it('tests a value with prototype of null', function () { + it('tests a value with prototype of null', function() { eq(RA.isPlainObj(Object.create(null)), true); const object = Object.create(null); @@ -29,21 +28,21 @@ describe('isPlainObj', function () { eq(RA.isPlainObj(object), true); }); - it('tests a value with `valueOf` property', function () { + it('tests a value with `valueOf` property', function() { eq(RA.isPlainObj({ valueOf: 1 }), true); }); - it('test a value with custom prototype', function () { + it('test a value with custom prototype', function() { eq(RA.isPlainObj(Object.create({ a: 3 })), true); }); - it('test a value that is DOM element', function () { + it('test a value that is DOM element', function() { if (element) { eq(RA.isPlainObj(element), false); } }); - it('test a value for non-objects', function () { + it('test a value for non-objects', function() { eq(RA.isPlainObj(args), false); eq(RA.isPlainObj(Error), false); eq(RA.isPlainObj(Math), false); @@ -51,16 +50,15 @@ describe('isPlainObj', function () { eq(RA.isPlainObj('abc'), false); }); - it('test a value for Symbol', function () { + it('test a value for Symbol', function() { if (Symbol) { eq(RA.isPlainObj(Symbol.for('symbol')), false); } }); }); -describe('isPlainObject', function () { - it('tests an alias', function () { +describe('isPlainObject', function() { + it('tests an alias', function() { eq(RA.isPlainObj === RA.isPlainObject, true); }); }); - diff --git a/test/isPositive.js b/test/isPositive.js index 4e6a11ca3d..0988649978 100644 --- a/test/isPositive.js +++ b/test/isPositive.js @@ -5,9 +5,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isPositive', function () { - it('tests a value for positive `Number`', function () { +describe('isPositive', function() { + it('tests a value for positive `Number`', function() { eq(RA.isPositive(0), false); eq(RA.isPositive(0.1), true); eq(RA.isPositive(Object(0)), false); diff --git a/test/isPromise.js b/test/isPromise.js index 053272c94b..6240712137 100644 --- a/test/isPromise.js +++ b/test/isPromise.js @@ -5,10 +5,9 @@ import eq from './shared/eq'; import Symbol from './shared/Symbol'; import args from './shared/arguments'; - -describe('isPromise', function () { - context('when value is not a Promise', function () { - specify('should return false', function () { +describe('isPromise', function() { + context('when value is not a Promise', function() { + specify('should return false', function() { eq(RA.isPromise(args), false); eq(RA.isPromise([1, 2, 3]), false); eq(RA.isPromise(true), false); @@ -22,24 +21,26 @@ describe('isPromise', function () { }); }); - context('when value is thenable object', function () { - specify('should return false', function () { + context('when value is thenable object', function() { + specify('should return false', function() { eq(RA.isPromise({ then: () => {} }), false); }); }); - context("when value contains then method on it's prototype", function () { - specify('should return false', function () { + context("when value contains then method on it's prototype", function() { + specify('should return false', function() { const objWithPrototype = Object.create({ then: () => {} }); eq(RA.isPromise(objWithPrototype), false); }); }); - context('when value is an instance of native Promise', function () { - const hasNativePromise = typeof Promise !== 'undefined' && contains('[native code]', Promise.toString()); + context('when value is an instance of native Promise', function() { + const hasNativePromise = + typeof Promise !== 'undefined' && + contains('[native code]', Promise.toString()); - specify('should return true', function () { + specify('should return true', function() { const resolvedP = Promise.resolve(); const rejectedP = Promise.reject(); @@ -50,8 +51,8 @@ describe('isPromise', function () { }); }); - context('when value is a thenable function', function () { - specify('should return false', function () { + context('when value is a thenable function', function() { + specify('should return false', function() { const func = () => {}; func.then = () => {}; diff --git a/test/isRegExp.js b/test/isRegExp.js index d0bbd7697b..d7e4c415b6 100644 --- a/test/isRegExp.js +++ b/test/isRegExp.js @@ -3,9 +3,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isRegExp', function () { - it('tests a value for `RegExp`', function () { +describe('isRegExp', function() { + it('tests a value for `RegExp`', function() { eq(RA.isRegExp(new RegExp()), true); eq(RA.isRegExp(/(?:)/), true); @@ -17,14 +16,13 @@ describe('isRegExp', function () { eq(RA.isRegExp(false), false); eq(RA.isRegExp(new Error()), false); eq(RA.isRegExp(new Date()), false); - eq(RA.isRegExp(function () {}), false); + eq(RA.isRegExp(function() {}), false); eq(RA.isRegExp(Object(0)), false); eq(RA.isRegExp(Object('a')), false); eq(RA.isRegExp(Object(false)), false); eq(RA.isRegExp(RA), false); eq(RA.isRegExp(args), false); - if (Symbol !== 'undefined') { eq(RA.isRegExp(Symbol), false); } diff --git a/test/isString.js b/test/isString.js index f895592906..a7784e67f4 100644 --- a/test/isString.js +++ b/test/isString.js @@ -3,9 +3,8 @@ import eq from './shared/eq'; import Symbol from './shared/Symbol'; import args from './shared/arguments'; - -describe('isString', function () { - it('tests a value for `String`', function () { +describe('isString', function() { + it('tests a value for `String`', function() { eq(RA.isString('abc'), true); eq(RA.isString(Object('abc')), true); diff --git a/test/isThenable.js b/test/isThenable.js index 8d4ea2155b..174a81a047 100644 --- a/test/isThenable.js +++ b/test/isThenable.js @@ -3,10 +3,9 @@ import eq from './shared/eq'; import Symbol from './shared/Symbol'; import args from './shared/arguments'; - -describe('isThenable', function () { - context('when value is not `thenable`', function () { - specify('should return false', function () { +describe('isThenable', function() { + context('when value is not `thenable`', function() { + specify('should return false', function() { eq(RA.isThenable(args), false); eq(RA.isThenable([1, 2, 3]), false); eq(RA.isThenable(true), false); @@ -20,22 +19,22 @@ describe('isThenable', function () { }); }); - context('when value is thenable object', function () { - specify('should return true', function () { + context('when value is thenable object', function() { + specify('should return true', function() { eq(RA.isThenable({ then: () => {} }), true); }); }); - context("when value contains then method on it's prototype", function () { - specify('should return true', function () { + context("when value contains then method on it's prototype", function() { + specify('should return true', function() { const objWithPrototype = Object.create({ then: () => {} }); eq(RA.isThenable(objWithPrototype), true); }); }); - context('when value is an instance of native Promise', function () { - specify('should return true', function () { + context('when value is an instance of native Promise', function() { + specify('should return true', function() { const resolvedP = Promise.resolve(); const rejectedP = Promise.reject(); @@ -46,8 +45,8 @@ describe('isThenable', function () { }); }); - context('when value is a thenable function', function () { - specify('should return true', function () { + context('when value is a thenable function', function() { + specify('should return true', function() { const func = () => {}; func.then = () => {}; diff --git a/test/isTruthy.js b/test/isTruthy.js index 71b68c710d..d122c0ad2a 100644 --- a/test/isTruthy.js +++ b/test/isTruthy.js @@ -3,9 +3,8 @@ import eq from './shared/eq'; import Symbol from './shared/Symbol'; import args from './shared/arguments'; - -describe('isTruthy', function () { - it('tests a value for `truthy`', function () { +describe('isTruthy', function() { + it('tests a value for `truthy`', function() { eq(RA.isTruthy('abc'), true); eq(RA.isTruthy(Object('abc')), true); eq(RA.isTruthy(args), true); diff --git a/test/isUndefined.js b/test/isUndefined.js index ebd176b348..6a97447f5e 100644 --- a/test/isUndefined.js +++ b/test/isUndefined.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('isUndefined', function () { - it('tests a value for `undefined`', function () { +describe('isUndefined', function() { + it('tests a value for `undefined`', function() { eq(RA.isUndefined(void 0), true); eq(RA.isUndefined(undefined), true); eq(RA.isUndefined(null), false); diff --git a/test/isValidDate.js b/test/isValidDate.js index 3e4687445f..762b0c6cf0 100644 --- a/test/isValidDate.js +++ b/test/isValidDate.js @@ -3,9 +3,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isValidDate', function () { - it('tests a value for a valid `Date`', function () { +describe('isValidDate', function() { + it('tests a value for a valid `Date`', function() { eq(RA.isValidDate(new Date()), true); eq(RA.isValidDate(new Date('a')), false); diff --git a/test/isValidNumber.js b/test/isValidNumber.js index 35c07c7657..05130276cf 100644 --- a/test/isValidNumber.js +++ b/test/isValidNumber.js @@ -5,9 +5,8 @@ import eq from './shared/eq'; import args from './shared/arguments'; import Symbol from './shared/Symbol'; - -describe('isValidNumber', function () { - it('tests a value for a valid `Number`', function () { +describe('isValidNumber', function() { + it('tests a value for a valid `Number`', function() { eq(RA.isValidNumber(0), true); eq(RA.isValidNumber(0.1), true); eq(RA.isValidNumber(-0.1), true); diff --git a/test/lensEq.js b/test/lensEq.js index 290bf07f58..a7b6e16585 100644 --- a/test/lensEq.js +++ b/test/lensEq.js @@ -3,9 +3,8 @@ import { lens, lensIndex, lensPath, lensProp, path } from 'ramda'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('lensEq', function () { - it('tests a lens for a value', function () { +describe('lensEq', function() { + it('tests a lens for a value', function() { eq(RA.lensEq(lensIndex(1), 1, [0, 1]), true); eq(RA.lensEq(lensIndex(0), 1, [0, 1]), false); eq(RA.lensEq(lensPath(['a', 'b']), 'foo', { a: { b: 'foo' } }), true); @@ -16,7 +15,7 @@ describe('lensEq', function () { eq(RA.lensEq(lensProp('foo'), 'bar', { bar: 'foo' }), false); }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.lensEq(lensIndex(1))(1)([0, 1]), true); eq(RA.lensEq(lensIndex(1), 1)([0, 1]), true); eq(RA.lensEq(lensIndex(1))(1, [0, 1]), true); diff --git a/test/lensIso.js b/test/lensIso.js index 807483dc94..d391797f69 100644 --- a/test/lensIso.js +++ b/test/lensIso.js @@ -3,49 +3,51 @@ import { view, set, over, assoc, replace } from 'ramda'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('lensIso', function () { +describe('lensIso', function() { const lensJSON = RA.lensIso(JSON.parse, JSON.stringify); - it('tests currying with arity 1', function () { + it('tests currying with arity 1', function() { const lensJSONA1 = RA.lensIso(JSON.parse)(JSON.stringify); eq(view(lensJSONA1, '{"a":1}'), { a: 1 }); }); - it('tests currying with arity 2', function () { + it('tests currying with arity 2', function() { eq(view(lensJSON, '{"a":1}'), { a: 1 }); }); - it('tests for `from` property', function () { + it('tests for `from` property', function() { eq(RA.isFunction(RA.lensIso.from), true); }); - it('tests reading through lens', function () { + it('tests reading through lens', function() { eq(view(lensJSON, '{"a":1}'), { a: 1 }); }); - it('tests writing through lens', function () { + it('tests writing through lens', function() { eq(set(lensJSON, { b: 2 }, '{"a": 1}'), '{"b":2}'); }); - it('tests applying a function over lens', function () { + it('tests applying a function over lens', function() { eq(over(lensJSON, assoc('b', 2), '{"a":1}'), '{"a":1,"b":2}'); }); - context('when reversed isomorphism', function () { + context('when reversed isomorphism', function() { const lensJSONReversed = RA.lensIso.from(lensJSON); - specify('test reading through lens', function () { + specify('test reading through lens', function() { eq(view(lensJSONReversed, { a: 1 }), '{"a":1}'); }); - specify('tests writing through lens', function () { + specify('tests writing through lens', function() { eq(set(lensJSONReversed, '{"b":2}', { a: 1 }), { b: 2 }); }); - specify('tests applying a function over lens', function () { - eq(over(lensJSONReversed, replace('}', ',"b":2}'), { a: 1 }), { a: 1, b: 2 }); + specify('tests applying a function over lens', function() { + eq(over(lensJSONReversed, replace('}', ',"b":2}'), { a: 1 }), { + a: 1, + b: 2, + }); }); }); }); diff --git a/test/lensNotEq.js b/test/lensNotEq.js index 67e8aa1088..aab67f99af 100644 --- a/test/lensNotEq.js +++ b/test/lensNotEq.js @@ -3,9 +3,8 @@ import { lens, lensIndex, lensPath, lensProp, path } from 'ramda'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('lensNotEq', function () { - it('tests a lens for a value', function () { +describe('lensNotEq', function() { + it('tests a lens for a value', function() { eq(RA.lensNotEq(lensIndex(1), 1, [0, 1]), false); eq(RA.lensNotEq(lensIndex(0), 1, [0, 1]), true); eq(RA.lensNotEq(lensPath(['a', 'b']), 'foo', { a: { b: 'foo' } }), false); @@ -16,7 +15,7 @@ describe('lensNotEq', function () { eq(RA.lensNotEq(lensProp('foo'), 'bar', { bar: 'foo' }), true); }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.lensNotEq(lensIndex(1))(1)([0, 1]), false); eq(RA.lensNotEq(lensIndex(1), 1)([0, 1]), false); eq(RA.lensNotEq(lensIndex(1))(1, [0, 1]), false); diff --git a/test/lensNotSatisfy.js b/test/lensNotSatisfy.js index 8e769f9a18..ab12d64c94 100644 --- a/test/lensNotSatisfy.js +++ b/test/lensNotSatisfy.js @@ -3,27 +3,37 @@ import { lensIndex, lensPath, lensProp, equals, pathEq } from 'ramda'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('lensNotSatisfy', function () { - it('tests a lens not satisfying the predicate', function () { - eq(RA.lensNotSatisfy(equals('bar'), lensProp('foo'), { foo: 'bar' }), false); +describe('lensNotSatisfy', function() { + it('tests a lens not satisfying the predicate', function() { + eq( + RA.lensNotSatisfy(equals('bar'), lensProp('foo'), { foo: 'bar' }), + false + ); eq(RA.lensNotSatisfy(equals('foo'), lensProp('bar'), { foo: 'bar' }), true); eq(RA.lensNotSatisfy(x => x > 0, lensIndex(1), [0, 1, 2]), false); eq(RA.lensNotSatisfy(x => x > 0, lensIndex(0), [0, 1, 2]), true); eq( - RA.lensNotSatisfy( - pathEq(['foo', 'bar'], 42), - lensPath(['o1', 'o2']), { o1: { o2: { foo: { bar: 42 } } } } - ), + RA.lensNotSatisfy(pathEq(['foo', 'bar'], 42), lensPath(['o1', 'o2']), { + o1: { o2: { foo: { bar: 42 } } }, + }), false ); }); - it('tests currying', function () { - eq(RA.lensNotSatisfy(equals('bar'))(lensProp('foo'))({ foo: 'bar' }), false); - eq(RA.lensNotSatisfy(equals('bar'), lensProp('foo'))({ foo: 'bar' }), false); - eq(RA.lensNotSatisfy(equals('bar'))(lensProp('foo'))({ foo: 'bar' }), false); + it('tests currying', function() { + eq( + RA.lensNotSatisfy(equals('bar'))(lensProp('foo'))({ foo: 'bar' }), + false + ); + eq( + RA.lensNotSatisfy(equals('bar'), lensProp('foo'))({ foo: 'bar' }), + false + ); + eq( + RA.lensNotSatisfy(equals('bar'))(lensProp('foo'))({ foo: 'bar' }), + false + ); }); }); diff --git a/test/lensSatisfies.js b/test/lensSatisfies.js index 16d8e1d721..ca116e29ce 100644 --- a/test/lensSatisfies.js +++ b/test/lensSatisfies.js @@ -3,21 +3,23 @@ import { lensIndex, lensPath, lensProp, equals, pathEq } from 'ramda'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('lensSatisfies', function () { - it('tests a lens satisfying the predicate', function () { +describe('lensSatisfies', function() { + it('tests a lens satisfying the predicate', function() { eq(RA.lensSatisfies(equals('bar'), lensProp('foo'), { foo: 'bar' }), true); eq(RA.lensSatisfies(equals('foo'), lensProp('bar'), { foo: 'bar' }), false); eq(RA.lensSatisfies(x => x > 0, lensIndex(1), [0, 1, 2]), true); eq(RA.lensSatisfies(x => x > 0, lensIndex(0), [0, 1, 2]), false); - eq(RA.lensSatisfies(pathEq(['foo', 'bar'], 42), lensPath(['o1', 'o2']), { - o1: { o2: { foo: { bar: 42 } } }, - }), true); + eq( + RA.lensSatisfies(pathEq(['foo', 'bar'], 42), lensPath(['o1', 'o2']), { + o1: { o2: { foo: { bar: 42 } } }, + }), + true + ); }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.lensSatisfies(equals('bar'))(lensProp('foo'))({ foo: 'bar' }), true); eq(RA.lensSatisfies(equals('bar'), lensProp('foo'))({ foo: 'bar' }), true); eq(RA.lensSatisfies(equals('bar'))(lensProp('foo'))({ foo: 'bar' }), true); diff --git a/test/liftF.js b/test/liftF.js index 632d75a382..88cff17e1b 100644 --- a/test/liftF.js +++ b/test/liftF.js @@ -3,25 +3,33 @@ import { Maybe } from 'monet'; import * as RA from '../src/index'; import eq from './shared/eq'; - const add3 = (a, b, c) => a + b + c; const add4 = (a, b, c, d) => a + b + c + d; const add5 = (a, b, c, d, e) => a + b + c + d + e; -describe('liftF', function () { +describe('liftF', function() { const addF3 = RA.liftF(add3); const addF4 = RA.liftF(add4); const addF5 = RA.liftF(add5); - it('returns a function', function () { + it('returns a function', function() { eq(typeof RA.liftF(add3), 'function'); }); - it('can lift functions of any arity', function () { + it('can lift functions of any arity', function() { eq(addF3(Maybe.Some(1), Maybe.Some(1), Maybe.Some(1)), Maybe.Some(3)); - eq(addF4(Maybe.Some(1), Maybe.Some(1), Maybe.Some(1), Maybe.Some(1)), Maybe.Some(4)); eq( - addF5(Maybe.Some(1), Maybe.Some(1), Maybe.Some(1), Maybe.Some(1), Maybe.Some(1)), + addF4(Maybe.Some(1), Maybe.Some(1), Maybe.Some(1), Maybe.Some(1)), + Maybe.Some(4) + ); + eq( + addF5( + Maybe.Some(1), + Maybe.Some(1), + Maybe.Some(1), + Maybe.Some(1), + Maybe.Some(1) + ), Maybe.Some(5) ); }); diff --git a/test/liftFN.js b/test/liftFN.js index d0e5bc8605..3b1577c0b3 100644 --- a/test/liftFN.js +++ b/test/liftFN.js @@ -6,47 +6,70 @@ import * as RA from '../src/index'; import eq from './shared/eq'; import Identity from '../src/fantasy-land/Identity'; - const addN = (...args) => R.sum(args); const add3 = (a, b, c) => a + b + c; -describe('liftFN', function () { +describe('liftFN', function() { const addN3 = RA.liftFN(3, addN); const addN4 = RA.liftFN(4, addN); const addN5 = RA.liftFN(5, addN); - it('returns a function', function () { + it('returns a function', function() { eq(typeof RA.liftFN(3, add3), 'function'); }); - it('limits a variadic function to the specified arity', function () { + it('limits a variadic function to the specified arity', function() { eq(addN3(Maybe.Some(1), Maybe.Some(1), Maybe.Some(1)), Maybe.Some(3)); }); - it('throws error on variadic function is more arguments than arity', function () { + it('throws error on variadic function is more arguments than arity', function() { chai.assert.throws( - addN3.bind(null, Maybe.Some(1), Maybe.Some(1), Maybe.Some(1), Maybe.Some(1)), + addN3.bind( + null, + Maybe.Some(1), + Maybe.Some(1), + Maybe.Some(1), + Maybe.Some(1) + ), TypeError ); }); - it('can lift functions of any arity', function () { + it('can lift functions of any arity', function() { eq(addN3(Maybe.Some(1), Maybe.Some(1), Maybe.Some(1)), Maybe.Some(3)); - eq(addN4(Maybe.Some(1), Maybe.Some(1), Maybe.Some(1), Maybe.Some(1)), Maybe.Some(4)); eq( - addN5(Maybe.Some(1), Maybe.Some(1), Maybe.Some(1), Maybe.Some(1), Maybe.Some(1)), + addN4(Maybe.Some(1), Maybe.Some(1), Maybe.Some(1), Maybe.Some(1)), + Maybe.Some(4) + ); + eq( + addN5( + Maybe.Some(1), + Maybe.Some(1), + Maybe.Some(1), + Maybe.Some(1), + Maybe.Some(1) + ), Maybe.Some(5) ); }); - it('retain order of arguments', function () { - eq(RA.liftFN(3, add3)(Maybe.Some('a'), Maybe.Some('b'), Maybe.Some('c')), Maybe.Some('abc')); - eq(RA.liftFN(3, add3)(Identity.of('a'), Identity.of('b'), Identity.of('c')), Identity.of('abc')); + it('retain order of arguments', function() { + eq( + RA.liftFN(3, add3)(Maybe.Some('a'), Maybe.Some('b'), Maybe.Some('c')), + Maybe.Some('abc') + ); + eq( + RA.liftFN(3, add3)(Identity.of('a'), Identity.of('b'), Identity.of('c')), + Identity.of('abc') + ); }); - it('is curried', function () { + it('is curried', function() { const f4 = RA.liftFN(4); eq(typeof f4, 'function'); - eq(f4(addN)(Maybe.Some(1), Maybe.Some(1), Maybe.Some(1), Maybe.Some(1)), Maybe.Some(4)); + eq( + f4(addN)(Maybe.Some(1), Maybe.Some(1), Maybe.Some(1), Maybe.Some(1)), + Maybe.Some(4) + ); }); }); diff --git a/test/list.js b/test/list.js index a067548cd3..47cdbb169a 100644 --- a/test/list.js +++ b/test/list.js @@ -1,21 +1,20 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('list', function () { - it('tests creating list from items', function () { +describe('list', function() { + it('tests creating list from items', function() { eq(RA.list('a', 'b', 'c'), ['a', 'b', 'c']); }); - it('test creating list from another list', function () { + it('test creating list from another list', function() { eq(RA.list(['a', 'b']), [['a', 'b']]); }); - it('test creating list from undefined', function () { + it('test creating list from undefined', function() { eq(RA.list(undefined), [undefined]); }); - it('test creating empty list from empty items', function () { + it('test creating empty list from empty items', function() { eq(RA.list(), []); }); }); diff --git a/test/mapIndexed.js b/test/mapIndexed.js index 83e249b426..6708fef641 100644 --- a/test/mapIndexed.js +++ b/test/mapIndexed.js @@ -4,9 +4,8 @@ import * as R from 'ramda'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('mapIndexed', function () { - context('R.map', function () { +describe('mapIndexed', function() { + context('R.map', function() { const listXf = { '@@transducer/init': () => [], '@@transducer/step': (acc, x) => acc.concat([x]), @@ -17,53 +16,62 @@ describe('mapIndexed', function () { const dec = x => x - 1; const intoArray = R.into([]); - it('maps simple functions over arrays', function () { + it('maps simple functions over arrays', function() { eq(RA.mapIndexed(times2, [1, 2, 3, 4]), [2, 4, 6, 8]); }); - it('maps simple functions into arrays', function () { + it('maps simple functions into arrays', function() { eq(intoArray(RA.mapIndexed(times2), [1, 2, 3, 4]), [2, 4, 6, 8]); }); - it('maps over objects', function () { + it('maps over objects', function() { eq(RA.mapIndexed(dec, {}), {}); eq(RA.mapIndexed(dec, { x: 4, y: 5, z: 6 }), { x: 3, y: 4, z: 5 }); }); - it('interprets ((->) r) as a functor', function () { + it('interprets ((->) r) as a functor', function() { const f = a => a - 1; const g = b => b * 2; const h = RA.mapIndexed(f, g); - eq(h(10), (10 * 2) - 1); + eq(h(10), 10 * 2 - 1); }); - it('dispatches to objects that implement `map`', function () { - const obj = { x: 100, map: function fn(f) { return f(this.x) } }; + it('dispatches to objects that implement `map`', function() { + const obj = { + x: 100, + map: function fn(f) { + return f(this.x); + }, + }; eq(RA.mapIndexed(add1, obj), 101); }); - it('dispatches to transformer objects', function () { + it('dispatches to transformer objects', function() { const result = RA.mapIndexed(add1, listXf); eq(result.xf, listXf); eq(result.f(41), 42); }); - it('throws a TypeError on null and undefined', function () { - chai.assert.throws(function fn() { return RA.mapIndexed(times2, null) }, TypeError); - chai.assert.throws(function fn() { return RA.mapIndexed(times2, undefined) }, TypeError); + it('throws a TypeError on null and undefined', function() { + chai.assert.throws(function fn() { + return RA.mapIndexed(times2, null); + }, TypeError); + chai.assert.throws(function fn() { + return RA.mapIndexed(times2, undefined); + }, TypeError); }); - it('composes', function () { + it('composes', function() { const mdouble = RA.mapIndexed(times2); const mdec = RA.mapIndexed(dec); eq(mdec(mdouble([10, 20, 30])), [19, 39, 59]); }); - it('can compose transducer-style', function () { + it('can compose transducer-style', function() { const mdouble = RA.mapIndexed(times2); const mdec = RA.mapIndexed(dec); const xcomp = mdec(mdouble(listXf)); @@ -75,7 +83,7 @@ describe('mapIndexed', function () { // eq(xcomp.f, dec); }); - it('correctly uses fantasy-land implementations', function () { + it('correctly uses fantasy-land implementations', function() { const m1 = RA.Identity.of(1); const m2 = RA.mapIndexed(R.add(1), m1); @@ -83,8 +91,8 @@ describe('mapIndexed', function () { }); }); - context('documentation example', function () { - specify('should join idx and value with a "-"', function () { + context('documentation example', function() { + specify('should join idx and value with a "-"', function() { const initialList = ['f', 'o', 'o', 'b', 'a', 'r']; const resultList = ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r']; @@ -92,9 +100,9 @@ describe('mapIndexed', function () { }); }); - context('third argument', function () { + context('third argument', function() { const initialList = ['f', 'o', 'o', 'b', 'a', 'r']; - specify('should be the same reference that original list', function () { + specify('should be the same reference that original list', function() { RA.mapIndexed((val, idx, list) => { chai.assert.strictEqual(list, initialList); return val; diff --git a/test/mergePath.js b/test/mergePath.js index 8d32513caa..fdee4cc070 100644 --- a/test/mergePath.js +++ b/test/mergePath.js @@ -1,41 +1,40 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('mergePath', function () { +describe('mergePath', function() { let path; let source; let obj; let expected; - beforeEach(function () { + beforeEach(function() { path = ['a', 'b']; source = { c2: 22, c3: 33 }; obj = { a: { b: { c1: 1, c2: 2 } } }; expected = { a: { b: { c1: 1, c2: 22, c3: 33 } } }; }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.mergePath(path, source, obj), expected); eq(RA.mergePath(path)(source, obj), expected); eq(RA.mergePath(path, source)(obj), expected); eq(RA.mergePath(path)(source)(obj), expected); }); - it('tests merging the property paths containing object', function () { + it('tests merging the property paths containing object', function() { eq(RA.mergePath(path, source, obj), expected); }); - it('returns unmodified object when source empty', function () { + it('returns unmodified object when source empty', function() { eq(RA.mergePath(path, {}, obj), obj); }); - it('creates object with subject under path when obj empty', function () { + it('creates object with subject under path when obj empty', function() { expected = { a: { b: { c2: 22, c3: 33 } } }; eq(RA.mergePath(path, source, {}), expected); }); - it('creates object with subject under path when target is not object', function () { + it('creates object with subject under path when target is not object', function() { expected = { a: { b: { c2: 22, c3: 33 } } }; eq(RA.mergePath(path, source, { a: { b: 1 } }), expected); }); diff --git a/test/mergePaths.js b/test/mergePaths.js index db7a04ad46..60045b4cfb 100644 --- a/test/mergePaths.js +++ b/test/mergePaths.js @@ -1,12 +1,11 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('mergePaths', function () { +describe('mergePaths', function() { let obj; let expected; - beforeEach(function () { + beforeEach(function() { obj = { foo: { fooinner: { fooinner2: 1 } }, bar: { barinner: 2 }, @@ -14,22 +13,42 @@ describe('mergePaths', function () { expected = { fooinner2: 1, barinner: 2 }; }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.mergePaths([['foo', 'fooinner'], ['bar']], obj), expected); eq(RA.mergePaths([['foo', 'fooinner'], ['bar']])(obj), expected); }); - it('tests merging the property paths containing object', function () { + it('tests merging the property paths containing object', function() { eq(RA.mergePaths([['foo', 'fooinner'], ['bar']], obj), expected); }); - it('tests merging the property paths containing non-objects', function () { - eq(RA.mergePaths([['foo', 'fooinner'], ['bar']], { foo: { fooinner: 1 }, bar: 2 }), {}); - eq(RA.mergePaths([['foo', 'fooinner'], ['bar']], { foo: { fooinner: 'a' }, bar: 'b' }), { 0: 'b' }); - eq(RA.mergePaths([['foo', 'fooinner'], ['bar']], { foo: { fooinner: null }, bar: undefined }), {}); + it('tests merging the property paths containing non-objects', function() { + eq( + RA.mergePaths([['foo', 'fooinner'], ['bar']], { + foo: { fooinner: 1 }, + bar: 2, + }), + {} + ); + eq( + RA.mergePaths([['foo', 'fooinner'], ['bar']], { + foo: { fooinner: 'a' }, + bar: 'b', + }), + { + 0: 'b', + } + ); + eq( + RA.mergePaths([['foo', 'fooinner'], ['bar']], { + foo: { fooinner: null }, + bar: undefined, + }), + {} + ); }); - it('tests if no paths requested', function () { + it('tests if no paths requested', function() { eq(RA.mergePaths([], obj), {}); }); }); diff --git a/test/mergeProp.js b/test/mergeProp.js index ebf19fee57..2f43d484c5 100644 --- a/test/mergeProp.js +++ b/test/mergeProp.js @@ -1,41 +1,40 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('mergeProp', function () { +describe('mergeProp', function() { let prop; let source; let obj; let expected; - beforeEach(function () { + beforeEach(function() { prop = 'a'; source = { c2: 22, c3: 33 }; obj = { a: { c1: 1, c2: 2 } }; expected = { a: { c1: 1, c2: 22, c3: 33 } }; }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.mergeProp(prop, source, obj), expected); eq(RA.mergeProp(prop)(source, obj), expected); eq(RA.mergeProp(prop, source)(obj), expected); eq(RA.mergeProp(prop)(source)(obj), expected); }); - it('tests merging the property paths containing object', function () { + it('tests merging the property paths containing object', function() { eq(RA.mergeProp(prop, source, obj), expected); }); - it('returns unmodified object when source empty', function () { + it('returns unmodified object when source empty', function() { eq(RA.mergeProp(prop, {}, obj), obj); }); - it('creates object with subject under prop when obj empty', function () { + it('creates object with subject under prop when obj empty', function() { expected = { a: { c2: 22, c3: 33 } }; eq(RA.mergeProp(prop, source, {}), expected); }); - it('creates object with subject under prop when target is not object', function () { + it('creates object with subject under prop when target is not object', function() { expected = { a: { c2: 22, c3: 33 } }; eq(RA.mergeProp(prop, source, { a: 1 }), expected); }); diff --git a/test/mergeProps.js b/test/mergeProps.js index c5f34a95f6..bf577614d6 100644 --- a/test/mergeProps.js +++ b/test/mergeProps.js @@ -1,12 +1,11 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('mergeProps', function () { +describe('mergeProps', function() { let obj; let expected; - beforeEach(function () { + beforeEach(function() { obj = { foo: { fooinner: 1 }, bar: { barinner: 2 }, @@ -14,22 +13,22 @@ describe('mergeProps', function () { expected = { fooinner: 1, barinner: 2 }; }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.mergeProps(['foo', 'bar'], obj), expected); eq(RA.mergeProps(['foo', 'bar'])(obj), expected); }); - it('tests merging the props containing objects', function () { + it('tests merging the props containing objects', function() { eq(RA.mergeProps(['foo', 'bar'], obj), expected); }); - it('tests merging the props containing non-objects', function () { + it('tests merging the props containing non-objects', function() { eq(RA.mergeProps(['foo', 'bar'], { foo: 1, bar: 2 }), {}); eq(RA.mergeProps(['foo', 'bar'], { foo: 'a', bar: 'b' }), { 0: 'b' }); eq(RA.mergeProps(['foo', 'bar'], { foo: null, bar: undefined }), {}); }); - it('tests if no props requested', function () { + it('tests if no props requested', function() { eq(RA.mergeProps([], { foo: 1, bar: 2 }), {}); }); }); diff --git a/test/mergeRight.js b/test/mergeRight.js index e8362c5d44..bd4735e324 100644 --- a/test/mergeRight.js +++ b/test/mergeRight.js @@ -4,21 +4,20 @@ import * as R from 'ramda'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('mergeRight', function () { - it('takes two objects, merges their own properties and returns a new object', function () { +describe('mergeRight', function() { + it('takes two objects, merges their own properties and returns a new object', function() { const a = { w: 1, x: 2 }; const b = { y: 3, z: 4 }; eq(RA.mergeRight(a, b), { w: 1, x: 2, y: 3, z: 4 }); }); - it('overrides properties in the seconds object with properties in the first object', function () { + it('overrides properties in the seconds object with properties in the first object', function() { const a = { w: 1, x: 2 }; const b = { w: 100, y: 3, z: 4 }; eq(RA.mergeRight(b, a), { w: 100, x: 2, y: 3, z: 4 }); }); - it('is not destructive', function () { + it('is not destructive', function() { const a = { w: 1, x: 2 }; const res = RA.mergeRight({ x: 5 }, a); @@ -26,7 +25,7 @@ describe('mergeRight', function () { eq(res, { w: 1, x: 5 }); }); - it('reports only own properties', function () { + it('reports only own properties', function() { const a = { w: 1, x: 2 }; function Cla() {} Cla.prototype.x = 5; @@ -34,21 +33,20 @@ describe('mergeRight', function () { eq(RA.mergeRight(new Cla(), a), { w: 1, x: 2 }); }); - it('is curried', function () { + it('is curried', function() { const curried = RA.mergeRight({ w: 1, x: 2 }); const b = { y: 3, z: 4 }; eq(curried(b), { w: 1, x: 2, y: 3, z: 4 }); }); - it('is curried with placeholder', function () { + it('is curried with placeholder', function() { const curried = RA.mergeRight({ w: 1, x: 2 }, R.__); eq(curried({ x: 3, y: 4 }), { w: 1, x: 2, y: 4 }); }); }); -describe('resetToDefault', function () { - it('tests an alias', function () { +describe('resetToDefault', function() { + it('tests an alias', function() { eq(RA.mergeRight === RA.resetToDefault, true); }); }); - diff --git a/test/mocha-bootstrap.js b/test/mocha-bootstrap.js index 2dfa0f6a5c..a1756c9888 100644 --- a/test/mocha-bootstrap.js +++ b/test/mocha-bootstrap.js @@ -4,9 +4,7 @@ require('babel-register')({ // ignore: [/node_modules\/(?!(chai-as-promised))/], }); - const chai = require('chai'); const chaiAsPromised = require('chai-as-promised'); - chai.use(chaiAsPromised); diff --git a/test/neither.js b/test/neither.js index 27103c7728..e616d66a1b 100644 --- a/test/neither.js +++ b/test/neither.js @@ -5,7 +5,6 @@ import sinon from 'sinon'; import * as RA from '../src/index'; import eq from './shared/eq'; - const supportsFantasyLand = () => { try { return RA.neither(Just(false), Just(true)).equals(Just(false)); @@ -14,10 +13,10 @@ const supportsFantasyLand = () => { } }; -describe('neither', function () { +describe('neither', function() { const isFantasyLandSupported = supportsFantasyLand(); - it('combines two boolean-returning functions into one', function () { + it('combines two boolean-returning functions into one', function() { const even = x => x % 2 === 0; const gt10 = x => x > 10; const f = RA.neither(even, gt10); @@ -28,7 +27,7 @@ describe('neither', function () { eq(f(9), true); }); - it('accepts functions that take multiple parameters', function () { + it('accepts functions that take multiple parameters', function() { const between = (a, b, c) => a < b && b < c; const total20 = (a, b, c) => a + b + c === 20; const f = RA.neither(between, total20); @@ -39,8 +38,8 @@ describe('neither', function () { eq(f(12, 2, 7), true); }); - context('when the result of first function is true', function () { - specify('should not evaluate the second expression', function () { + context('when the result of first function is true', function() { + specify('should not evaluate the second expression', function() { const z = sinon.spy(); RA.neither(R.T, z)(); @@ -49,7 +48,7 @@ describe('neither', function () { }); if (isFantasyLandSupported) { - it('accepts fantasy-land applicative functors', function () { + it('accepts fantasy-land applicative functors', function() { eq(RA.neither(Just(true), Just(true)), Just(false)); eq(RA.neither(Just(true), Just(false)), Just(false)); eq(RA.neither(Just(false), Just(true)), Just(false)); diff --git a/test/nonePass.js b/test/nonePass.js index 328ec52cf7..2dfa3d826c 100644 --- a/test/nonePass.js +++ b/test/nonePass.js @@ -1,14 +1,13 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('nonePass', function () { +describe('nonePass', function() { const odd = n => n % 2 !== 0; const divBy3 = n => n % 3 === 0; const lt20 = n => n < 20; const plusEq = (w, x, y, z) => w + x === y + z; - it('reports whether all predicates are satisfied by a given value', function () { + it('reports whether all predicates are satisfied by a given value', function() { const ok = RA.nonePass([odd, divBy3, lt20]); eq(ok(9), false); // all ps succeed eq(ok(12), false); // p1 fails @@ -20,11 +19,11 @@ describe('nonePass', function () { eq(ok(26), true); // all ps fail }); - it('returns true on empty predicate list', function () { + it('returns true on empty predicate list', function() { eq(RA.nonePass([])(3), true); }); - it('returns a curried function whose arity matches that of the highest-arity predicate', function () { + it('returns a curried function whose arity matches that of the highest-arity predicate', function() { eq(RA.nonePass([odd, divBy3, plusEq]).length, 4); eq(RA.nonePass([odd, divBy3, plusEq])(26, 26, 26, 28), true); eq(RA.nonePass([odd, divBy3, plusEq])(26)(26)(26)(28), true); diff --git a/test/noop.js b/test/noop.js index 708e6758f1..3befc491fd 100644 --- a/test/noop.js +++ b/test/noop.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('noop', function () { - it('tests `function` that performs no operations', function () { +describe('noop', function() { + it('tests `function` that performs no operations', function() { eq(RA.noop(), undefined); eq(RA.noop([1]), undefined); eq(RA.noop(new Array()), undefined); diff --git a/test/notAllPass.js b/test/notAllPass.js index 304909a67c..8e37804d05 100644 --- a/test/notAllPass.js +++ b/test/notAllPass.js @@ -1,14 +1,13 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('notAllPass', function () { +describe('notAllPass', function() { const odd = n => n % 2 !== 0; const lt20 = n => n < 20; const gt5 = n => n > 5; const plusEq = (w, x, y, z) => w + x === y + z; - it('reports whether all predicates are satisfied by a given value', function () { + it('reports whether all predicates are satisfied by a given value', function() { const ok = RA.notAllPass([odd, lt20, gt5]); eq(ok(7), false); // all ps succeed eq(ok(10), true); // p1 fails @@ -18,11 +17,11 @@ describe('notAllPass', function () { eq(ok(4), true); // p1 and p3 fails }); - it('returns false on empty predicate list', function () { + it('returns false on empty predicate list', function() { eq(RA.notAllPass([])(3), false); }); - it('returns a curried function whose arity matches that of the highest-arity predicate', function () { + it('returns a curried function whose arity matches that of the highest-arity predicate', function() { eq(RA.notAllPass([odd, gt5, plusEq]).length, 4); eq(RA.notAllPass([odd, gt5, plusEq])(9, 9, 9, 10), true); eq(RA.notAllPass([odd, gt5, plusEq])(9)(9)(9)(10), true); diff --git a/test/notBoth.js b/test/notBoth.js index 9cd6afe8af..a0f7eaa413 100644 --- a/test/notBoth.js +++ b/test/notBoth.js @@ -5,7 +5,6 @@ import sinon from 'sinon'; import * as RA from '../src/index'; import eq from './shared/eq'; - const supportsFantasyLand = () => { try { return RA.notBoth(Just(true), Just(true)).equals(Just(false)); @@ -14,10 +13,10 @@ const supportsFantasyLand = () => { } }; -describe('notBoth', function () { +describe('notBoth', function() { const isFantasyLandSupported = supportsFantasyLand(); - it('combines two boolean-returning functions into one', function () { + it('combines two boolean-returning functions into one', function() { const even = x => x % 2 === 0; const gt10 = x => x > 10; const f = RA.notBoth(even, gt10); @@ -28,7 +27,7 @@ describe('notBoth', function () { eq(f(14), false); }); - it('accepts functions that take multiple parameters', function () { + it('accepts functions that take multiple parameters', function() { const between = (a, b, c) => a < b && b < c; const total20 = (a, b, c) => a + b + c === 20; const f = RA.notBoth(between, total20); @@ -39,8 +38,8 @@ describe('notBoth', function () { eq(f(5, 6, 15), true); }); - context('when the first function returns false', function () { - specify('should not evaluate the second function', function () { + context('when the first function returns false', function() { + specify('should not evaluate the second function', function() { const z = sinon.spy(); RA.notBoth(R.F, z)(); @@ -49,7 +48,7 @@ describe('notBoth', function () { }); if (isFantasyLandSupported) { - it('accepts fantasy-land applicative functors', function () { + it('accepts fantasy-land applicative functors', function() { eq(RA.notBoth(Just(true), Just(true)), Just(false)); eq(RA.notBoth(Just(true), Just(false)), Just(true)); eq(RA.notBoth(Just(false), Just(true)), Just(true)); diff --git a/test/omitIndexes.js b/test/omitIndexes.js index 39f2ed122c..fc011da11d 100644 --- a/test/omitIndexes.js +++ b/test/omitIndexes.js @@ -3,55 +3,57 @@ import chai from 'chai'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('omitIndexes', function () { +describe('omitIndexes', function() { let list; - beforeEach(function () { + beforeEach(function() { list = ['a', 'b', 'c', 'd']; }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.omitIndexes([], []), []); eq(RA.omitIndexes([])([]), []); }); - it('tests omitting values from list by indexes', function () { + it('tests omitting values from list by indexes', function() { eq(RA.omitIndexes([0, 2], list), ['b', 'd']); }); - context("when indexes doesn't exist", function () { - specify('should skip these indexes', function () { + context("when indexes doesn't exist", function() { + specify('should skip these indexes', function() { eq(RA.omitIndexes([-1, 0, 2, 5], list), ['b', 'd']); }); }); - context('when indexes is a non-array', function () { - specify('should produce TypeError', function () { + context('when indexes is a non-array', function() { + specify('should produce TypeError', function() { chai.assert.throws(RA.omitIndexes.bind(null, undefined, list), TypeError); }); }); - context('when list is a non-array', function () { - specify('should product TypeError', function () { - chai.assert.throws(RA.omitIndexes.bind(null, [0, 2], undefined), TypeError); + context('when list is a non-array', function() { + specify('should product TypeError', function() { + chai.assert.throws( + RA.omitIndexes.bind(null, [0, 2], undefined), + TypeError + ); }); }); - context('when empty indexes', function () { - specify('should return original array', function () { + context('when empty indexes', function() { + specify('should return original array', function() { eq(RA.omitIndexes([], list), list); }); }); - context('when empty list', function () { - specify('should return empty array', function () { + context('when empty list', function() { + specify('should return empty array', function() { eq(RA.omitIndexes([0, 1, 2], []), []); }); }); - context('when empty indexes and list', function () { - specify('should return empty array', function () { + context('when empty indexes and list', function() { + specify('should return empty array', function() { eq(RA.omitIndexes([], []), []); }); }); diff --git a/test/pathNotEq.js b/test/pathNotEq.js index 0c2e739441..197fe2873f 100644 --- a/test/pathNotEq.js +++ b/test/pathNotEq.js @@ -3,72 +3,76 @@ import * as R from 'ramda'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('pathNotEq', function () { +describe('pathNotEq', function() { let obj; - beforeEach(function () { + beforeEach(function() { obj = { a: { b: 1 } }; }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.pathNotEq(['a', 'b'], 'foo', obj), true); eq(RA.pathNotEq(['a', 'b'])('foo', obj), true); eq(RA.pathNotEq(['a', 'b'], 'foo')(obj), true); eq(RA.pathNotEq(['a', 'b'])('foo')(obj), true); }); - it('tests path value is not equal', function () { + it('tests path value is not equal', function() { eq(RA.pathNotEq(['a', 'b'], 'foo', obj), true); }); - it('tests path value is equal', function () { + it('tests path value is equal', function() { eq(RA.pathNotEq(['a', 'b'], 1, obj), false); }); - it('has R.equals semantics', function () { - function Just(x) { this.value = x } - Just.prototype.equals = function (x) { + it('has R.equals semantics', function() { + function Just(x) { + this.value = x; + } + Just.prototype.equals = function(x) { return x instanceof Just && R.equals(x.value, this.value); }; eq(RA.pathNotEq(['a', 'b'], 0, { a: { b: -0 } }), true); eq(RA.pathNotEq(['a', 'b'], -0, { a: { b: 0 } }), true); eq(RA.pathNotEq(['a', 'b'], NaN, { a: { b: NaN } }), false); - eq(RA.pathNotEq(['a', 'b'], new Just([42]), { a: { b: new Just([42]) } }), false); + eq( + RA.pathNotEq(['a', 'b'], new Just([42]), { a: { b: new Just([42]) } }), + false + ); }); - context('when there is no path', function () { - specify('should return true', function () { + context('when there is no path', function() { + specify('should return true', function() { eq(RA.pathNotEq(['bar', 'baz'], 'foo', obj), true); }); }); - context('when data is array and path consists integers', function () { - context('and array contains provided path', function () { + context('when data is array and path consists integers', function() { + context('and array contains provided path', function() { // eslint-disable-next-line mocha/no-hooks-for-single-case - beforeEach(function () { + beforeEach(function() { obj = [['a', 'b', 'c'], ['d', 'f']]; }); - specify('should return false', function () { + specify('should return false', function() { eq(RA.pathNotEq([0, 1], 'b', obj), false); }); }); - context('and array does not contains provided path', function () { + context('and array does not contains provided path', function() { // eslint-disable-next-line mocha/no-hooks-for-single-case - beforeEach(function () { + beforeEach(function() { obj = [['a', 'b', 'c'], ['d', 'f']]; }); - specify('should return true', function () { + specify('should return true', function() { eq(RA.pathNotEq([999, 999], 'x', obj), true); }); }); }); - it('tests example', function () { + it('tests example', function() { const user1 = { address: { zipCode: 90210 } }; const user2 = { address: { zipCode: 55555 } }; const user3 = { name: 'Bob' }; diff --git a/test/paths.js b/test/paths.js index b691d2d2d4..092491ec4c 100644 --- a/test/paths.js +++ b/test/paths.js @@ -1,30 +1,29 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('paths', function () { +describe('paths', function() { const obj = { a: { b: { c: 1 } }, d: 4, e: 5, f: 6 }; - it('returns empty array if no paths requested', function () { + it('returns empty array if no paths requested', function() { eq(RA.paths([], obj), []); }); - it('returns values for requested paths', function () { + it('returns values for requested paths', function() { eq(RA.paths([['a', 'b', 'c'], ['e']], obj), [1, 5]); }); - it('preserves order', function () { + it('preserves order', function() { eq(RA.paths([['f'], ['a', 'b', 'c'], ['e']], obj), [6, 1, 5]); }); - it('returns undefined for nonexistent paths', function () { + it('returns undefined for nonexistent paths', function() { const ps = RA.paths([['d'], ['nonexistent']], obj); eq(ps.length, 2); eq(ps[0], 4); eq(ps[1], undefined); }); - it('is curried', function () { + it('is curried', function() { eq(RA.paths([['a', 'b', 'c'], ['d']])(obj), [1, 4]); }); }); diff --git a/test/pickIndexes.js b/test/pickIndexes.js index bafa88ce0d..3e4ec9b319 100644 --- a/test/pickIndexes.js +++ b/test/pickIndexes.js @@ -3,56 +3,57 @@ import chai from 'chai'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('pickIndexes', function () { +describe('pickIndexes', function() { let list; - beforeEach(function () { + beforeEach(function() { list = ['a', 'b', 'c']; }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.pickIndexes([], []), []); eq(RA.pickIndexes([])([]), []); }); - it('tests picking values from list by indexes', function () { + it('tests picking values from list by indexes', function() { eq(RA.pickIndexes([0, 2], list), ['a', 'c']); }); - context("when indexes doesn't exist", function () { - specify('should skip these indexes', function () { + context("when indexes doesn't exist", function() { + specify('should skip these indexes', function() { eq(RA.pickIndexes([-1, 0, 5], list), ['a']); }); }); - context('when indexes is a non-array', function () { - specify('should produce TypeError', function () { + context('when indexes is a non-array', function() { + specify('should produce TypeError', function() { chai.assert.throws(RA.pickIndexes.bind(null, undefined, list), TypeError); }); }); - - context('when list is a non-array', function () { - specify('should product TypeError', function () { - chai.assert.throws(RA.pickIndexes.bind(null, [0, 2], undefined), TypeError); + context('when list is a non-array', function() { + specify('should product TypeError', function() { + chai.assert.throws( + RA.pickIndexes.bind(null, [0, 2], undefined), + TypeError + ); }); }); - context('when empty indexes', function () { - specify('should return empty array', function () { + context('when empty indexes', function() { + specify('should return empty array', function() { eq(RA.pickIndexes([], list), []); }); }); - context('when empty list', function () { - specify('should return empty array', function () { + context('when empty list', function() { + specify('should return empty array', function() { eq(RA.pickIndexes([0, 1, 2], []), []); }); }); - context('when empty indexes and list', function () { - specify('should return empty array', function () { + context('when empty indexes and list', function() { + specify('should return empty array', function() { eq(RA.pickIndexes([], []), []); }); }); diff --git a/test/propNotEq.js b/test/propNotEq.js index 5fbfcb9dac..ac042816f5 100644 --- a/test/propNotEq.js +++ b/test/propNotEq.js @@ -3,32 +3,33 @@ import * as R from 'ramda'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('propNotEq', function () { +describe('propNotEq', function() { let obj; - beforeEach(function () { + beforeEach(function() { obj = { a: 1, b: 2 }; }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.propNotEq('a', 'foo', obj), true); eq(RA.propNotEq('a')('foo', obj), true); eq(RA.propNotEq('a', 'foo')(obj), true); eq(RA.propNotEq('a')('foo')(obj), true); }); - it('tests prop value is not equal', function () { + it('tests prop value is not equal', function() { eq(RA.propNotEq('a', 'foo', obj), true); }); - it('tests prop value is equal', function () { + it('tests prop value is equal', function() { eq(RA.propNotEq('a', 1, obj), false); }); - it('has R.equals semantics', function () { - function Just(x) { this.value = x } - Just.prototype.equals = function (x) { + it('has R.equals semantics', function() { + function Just(x) { + this.value = x; + } + Just.prototype.equals = function(x) { return x instanceof Just && R.equals(x.value, this.value); }; @@ -38,31 +39,31 @@ describe('propNotEq', function () { eq(RA.propNotEq('value', new Just([42]), { value: new Just([42]) }), false); }); - context('when there is no prop bar', function () { - specify('should return true', function () { + context('when there is no prop bar', function() { + specify('should return true', function() { eq(RA.propNotEq('bar', 'foo', obj), true); }); }); - context('when data is array and property name is integer', function () { - context('and array contains provided index', function () { + context('when data is array and property name is integer', function() { + context('and array contains provided index', function() { // eslint-disable-next-line mocha/no-hooks-for-single-case - beforeEach(function () { + beforeEach(function() { obj = ['a', 'b', 'c']; }); - specify('should return false', function () { + specify('should return false', function() { eq(RA.propNotEq(0, 'a', obj), false); }); }); - context('and array does not contains provided index', function () { + context('and array does not contains provided index', function() { // eslint-disable-next-line mocha/no-hooks-for-single-case - beforeEach(function () { + beforeEach(function() { obj = ['a', 'b', 'c']; }); - specify('should return true', function () { + specify('should return true', function() { eq(RA.propNotEq(0, 'x', obj), true); }); }); diff --git a/test/reduceIndexed.js b/test/reduceIndexed.js index 31b2548197..73d767b546 100644 --- a/test/reduceIndexed.js +++ b/test/reduceIndexed.js @@ -4,38 +4,43 @@ import * as R from 'ramda'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('reduceIndexed', function () { - context('R.reduce', function () { +describe('reduceIndexed', function() { + context('R.reduce', function() { const addition = (a, b) => a + b; const mult = (a, b) => a * b; - it('folds simple functions over arrays with the supplied accumulator', function () { + it('folds simple functions over arrays with the supplied accumulator', function() { eq(R.reduce(addition, 0, [1, 2, 3, 4]), 10); eq(R.reduce(mult, 1, [1, 2, 3, 4]), 24); }); - it('dispatches to objects that implement `reduce`', function () { - const obj = { x: [1, 2, 3], reduce: function fun() { return 'override' } }; + it('dispatches to objects that implement `reduce`', function() { + const obj = { + x: [1, 2, 3], + reduce: function fun() { + return 'override'; + }, + }; eq(R.reduce(addition, 0, obj), 'override'); eq(R.reduce(addition, 10, obj), 'override'); }); - it('returns the accumulator for an empty array', function () { + it('returns the accumulator for an empty array', function() { eq(R.reduce(addition, 0, []), 0); eq(R.reduce(mult, 1, []), 1); eq(R.reduce(R.concat, [], []), []); }); - it('uses the iterator of an object (and handles short-circuits)', function () { - const symIterator = (typeof Symbol !== 'undefined') ? Symbol.iterator : '@@iterator'; + it('uses the iterator of an object (and handles short-circuits)', function() { + const symIterator = + typeof Symbol !== 'undefined' ? Symbol.iterator : '@@iterator'; function Reducible(arr) { this.arr = arr; } - Reducible.prototype[symIterator] = function () { + Reducible.prototype[symIterator] = function() { const a = this.arr; return { _pos: 0, @@ -56,7 +61,7 @@ describe('reduceIndexed', function () { }; const xf = R.take(2); - const apendingT = { }; + const apendingT = {}; apendingT['@@transducer/result'] = R.identity; apendingT['@@transducer/step'] = R.flip(R.append); @@ -67,23 +72,34 @@ describe('reduceIndexed', function () { }); }); - context('documentation example', function () { - specify('should join idx and value with a "-"', function () { + context('documentation example', function() { + specify('should join idx and value with a "-"', function() { const initialList = ['f', 'o', 'o', 'b', 'a', 'r']; const resultAcc = '-f0-o1-o2-b3-a4-r5'; - eq(RA.reduceIndexed((acc, val, idx) => `${acc}-${val}${idx}`, '', initialList), resultAcc); + eq( + RA.reduceIndexed( + (acc, val, idx) => `${acc}-${val}${idx}`, + '', + initialList + ), + resultAcc + ); }); }); - context('fourth argument', function () { + context('fourth argument', function() { const initialList = ['f', 'o', 'o', 'b', 'a', 'r']; - specify('should be the same reference that original list', function () { - RA.reduceIndexed((acc, val, idx, list) => { - chai.assert.strictEqual(list, initialList); - return acc; - }, '', initialList); + specify('should be the same reference that original list', function() { + RA.reduceIndexed( + (acc, val, idx, list) => { + chai.assert.strictEqual(list, initialList); + return acc; + }, + '', + initialList + ); }); }); }); diff --git a/test/reduceP.js b/test/reduceP.js index 65dbdbb028..3abacff11e 100644 --- a/test/reduceP.js +++ b/test/reduceP.js @@ -4,56 +4,79 @@ import sinon from 'sinon'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('reduceP', function () { - it('folds simple functions over arrays with the supplied accumulator', function () { - const testAdd = RA.reduceP(R.add, 0, [1, 2, 3, 4]).then(actual => eq(actual, 10)); - const testMultiply = RA.reduceP(R.multiply, 1, [1, 2, 3, 4]).then(actual => eq(actual, 24)); +describe('reduceP', function() { + it('folds simple functions over arrays with the supplied accumulator', function() { + const testAdd = RA.reduceP(R.add, 0, [1, 2, 3, 4]).then(actual => + eq(actual, 10) + ); + const testMultiply = RA.reduceP(R.multiply, 1, [1, 2, 3, 4]).then(actual => + eq(actual, 24) + ); return Promise.all([testAdd, testMultiply]); }); - it('dispatches to objects that implement `reduce`', function () { - const obj = { x: [1, 2, 3], reduce() { return 'override' } }; - const test1 = RA.reduceP(R.add, 0, obj).then(actual => eq(actual, 'override')); - const test2 = RA.reduceP(R.add, 10, obj).then(actual => eq(actual, 'override')); + it('dispatches to objects that implement `reduce`', function() { + const obj = { + x: [1, 2, 3], + reduce() { + return 'override'; + }, + }; + const test1 = RA.reduceP(R.add, 0, obj).then(actual => + eq(actual, 'override') + ); + const test2 = RA.reduceP(R.add, 10, obj).then(actual => + eq(actual, 'override') + ); return Promise.all([test1, test2]); }); - it('returns the accumulator for an empty array', function () { + it('returns the accumulator for an empty array', function() { const testAdd = RA.reduceP(R.add, 0, []).then(actual => eq(actual, 0)); - const testMultiply = RA.reduceP(R.multiply, 1, []).then(actual => eq(actual, 1)); - const testConcat = RA.reduceP(R.concat, [], []).then(actual => eq(actual, [])); + const testMultiply = RA.reduceP(R.multiply, 1, []).then(actual => + eq(actual, 1) + ); + const testConcat = RA.reduceP(R.concat, [], []).then(actual => + eq(actual, []) + ); return Promise.all([testAdd, testMultiply, testConcat]); }); - it('is curried', function () { + it('is curried', function() { const sum = RA.reduceP(R.add)(0); const cat = RA.reduceP(R.concat)(''); const testSum = sum([1, 2, 3, 4]).then(actual => eq(actual, 10)); - const testConcat = cat(['1', '2', '3', '4']).then(actual => eq(actual, '1234')); + const testConcat = cat(['1', '2', '3', '4']).then(actual => + eq(actual, '1234') + ); return Promise.all([testSum, testConcat]); }); - it('correctly reports the arity of curried versions', function () { + it('correctly reports the arity of curried versions', function() { const sum = RA.reduceP(R.add, 0); eq(sum.length, 1); }); - it('tests initial value for promise', function () { - const testAdd = RA.reduceP(R.add, Promise.resolve(0), [1, 2, 3, 4]) - .then(actual => eq(actual, 10)); - const testMultiply = RA.reduceP(R.multiply, Promise.resolve(1), [1, 2, 3, 4]) - .then(actual => eq(actual, 24)); + it('tests initial value for promise', function() { + const testAdd = RA.reduceP(R.add, Promise.resolve(0), [1, 2, 3, 4]).then( + actual => eq(actual, 10) + ); + const testMultiply = RA.reduceP(R.multiply, Promise.resolve(1), [ + 1, + 2, + 3, + 4, + ]).then(actual => eq(actual, 24)); return Promise.all([testAdd, testMultiply]); }); - it('tests returning initial value when iterable is empty', function () { + it('tests returning initial value when iterable is empty', function() { const add = sinon.spy(); return RA.reduceP(add, 0, []) @@ -61,7 +84,7 @@ describe('reduceP', function () { .then(() => eq(add.called, false)); }); - it('tests returning initial value when iterable is empty (promise version)', function () { + it('tests returning initial value when iterable is empty (promise version)', function() { const add = sinon.spy(); return RA.reduceP(add, Promise.resolve(0), []) @@ -69,7 +92,7 @@ describe('reduceP', function () { .then(() => eq(add.called, false)); }); - it('tests if initial value is undefined', function () { + it('tests if initial value is undefined', function() { const add = sinon.spy(); return RA.reduceP(add, undefined, [1]) @@ -77,7 +100,7 @@ describe('reduceP', function () { .then(() => eq(add.called, false)); }); - it('tests if initial value is undefined (promise version)', function () { + it('tests if initial value is undefined (promise version)', function() { const add = sinon.spy(); return RA.reduceP(add, Promise.resolve(), [1]) @@ -85,29 +108,35 @@ describe('reduceP', function () { .then(() => eq(add.called, false)); }); - it('tests iterator wrapped in the promise', function () { - return RA.reduceP(R.add, 0, Promise.resolve([1, 2, 3])).then(actual => eq(actual, 6)); + it('tests iterator wrapped in the promise', function() { + return RA.reduceP(R.add, 0, Promise.resolve([1, 2, 3])).then(actual => + eq(actual, 6) + ); }); - it('tests iterator containing values and promises', function () { - return RA.reduceP(R.add, 0, [1, Promise.resolve(2), 3]).then(actual => eq(actual, 6)); + it('tests iterator containing values and promises', function() { + return RA.reduceP(R.add, 0, [1, Promise.resolve(2), 3]).then(actual => + eq(actual, 6) + ); }); - it('tests iterator wrapped in promise containing values and promises', function () { - return RA.reduceP(R.add, 0, Promise.resolve([1, Promise.resolve(2), 3])) - .then(actual => eq(actual, 6)); + it('tests iterator wrapped in promise containing values and promises', function() { + return RA.reduceP( + R.add, + 0, + Promise.resolve([1, Promise.resolve(2), 3]) + ).then(actual => eq(actual, 6)); }); - it('tests iterator function returning promises', function () { + it('tests iterator function returning promises', function() { return RA.reduceP( R.pipe(R.add, Promise.resolve.bind(Promise)), 0, Promise.resolve([1, Promise.resolve(2), 3]) - ) - .then(actual => eq(actual, 6)); + ).then(actual => eq(actual, 6)); }); - it('prefers the use of the iterator of an object over reduce (and handles short-circuits)', function () { + it('prefers the use of the iterator of an object over reduce (and handles short-circuits)', function() { // no support for @@transducer protocol yet }); }); diff --git a/test/reduceRightP.js b/test/reduceRightP.js index a5afa9c1f6..6dedb4b5ab 100644 --- a/test/reduceRightP.js +++ b/test/reduceRightP.js @@ -4,57 +4,80 @@ import sinon from 'sinon'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('reduceRightP', function () { - it('folds simple functions over arrays with the supplied accumulator', function () { - const testAdd = RA.reduceRightP(R.add, 0, [1, 2, 3, 4]).then(actual => eq(actual, 10)); - const testMultiply = RA.reduceRightP(R.multiply, 1, [1, 2, 3, 4]) - .then(actual => eq(actual, 24)); +describe('reduceRightP', function() { + it('folds simple functions over arrays with the supplied accumulator', function() { + const testAdd = RA.reduceRightP(R.add, 0, [1, 2, 3, 4]).then(actual => + eq(actual, 10) + ); + const testMultiply = RA.reduceRightP(R.multiply, 1, [1, 2, 3, 4]).then( + actual => eq(actual, 24) + ); return Promise.all([testAdd, testMultiply]); }); - it('should not dispatch to objects that implement `reduce`', function () { - const obj = { x: [1, 2, 3], reduce() { return 'override' } }; + it('should not dispatch to objects that implement `reduce`', function() { + const obj = { + x: [1, 2, 3], + reduce() { + return 'override'; + }, + }; const test1 = RA.reduceRightP(R.add, 0, obj).then(actual => eq(actual, 0)); - const test2 = RA.reduceRightP(R.add, 10, obj).then(actual => eq(actual, 10)); + const test2 = RA.reduceRightP(R.add, 10, obj).then(actual => + eq(actual, 10) + ); return Promise.all([test1, test2]); }); - it('returns the accumulator for an empty array', function () { + it('returns the accumulator for an empty array', function() { const testAdd = RA.reduceRightP(R.add, 0, []).then(actual => eq(actual, 0)); - const testMultiply = RA.reduceRightP(R.multiply, 1, []).then(actual => eq(actual, 1)); - const testConcat = RA.reduceRightP(R.concat, [], []).then(actual => eq(actual, [])); + const testMultiply = RA.reduceRightP(R.multiply, 1, []).then(actual => + eq(actual, 1) + ); + const testConcat = RA.reduceRightP(R.concat, [], []).then(actual => + eq(actual, []) + ); return Promise.all([testAdd, testMultiply, testConcat]); }); - it('is curried', function () { + it('is curried', function() { const sum = RA.reduceRightP(R.add)(0); const cat = RA.reduceRightP(R.concat)(''); const testSum = sum([1, 2, 3, 4]).then(actual => eq(actual, 10)); - const testConcat = cat(['1', '2', '3', '4']).then(actual => eq(actual, '1234')); + const testConcat = cat(['1', '2', '3', '4']).then(actual => + eq(actual, '1234') + ); return Promise.all([testSum, testConcat]); }); - it('correctly reports the arity of curried versions', function () { + it('correctly reports the arity of curried versions', function() { const sum = RA.reduceRightP(R.add, 0); eq(sum.length, 1); }); - it('tests initial value for promise', function () { - const testAdd = RA.reduceRightP(R.add, Promise.resolve(0), [1, 2, 3, 4]) - .then(actual => eq(actual, 10)); - const testMultiply = RA.reduceRightP(R.multiply, Promise.resolve(1), [1, 2, 3, 4]) - .then(actual => eq(actual, 24)); + it('tests initial value for promise', function() { + const testAdd = RA.reduceRightP(R.add, Promise.resolve(0), [ + 1, + 2, + 3, + 4, + ]).then(actual => eq(actual, 10)); + const testMultiply = RA.reduceRightP(R.multiply, Promise.resolve(1), [ + 1, + 2, + 3, + 4, + ]).then(actual => eq(actual, 24)); return Promise.all([testAdd, testMultiply]); }); - it('tests returning initial value when iterable is empty', function () { + it('tests returning initial value when iterable is empty', function() { const add = sinon.spy(); return RA.reduceRightP(add, 0, []) @@ -62,7 +85,7 @@ describe('reduceRightP', function () { .then(() => eq(add.called, false)); }); - it('tests returning initial value when iterable is empty (promise version)', function () { + it('tests returning initial value when iterable is empty (promise version)', function() { const add = sinon.spy(); return RA.reduceRightP(add, Promise.resolve(0), []) @@ -70,7 +93,7 @@ describe('reduceRightP', function () { .then(() => eq(add.called, false)); }); - it('tests if initial value is undefined', function () { + it('tests if initial value is undefined', function() { const add = sinon.spy(); return RA.reduceRightP(add, undefined, [1]) @@ -78,7 +101,7 @@ describe('reduceRightP', function () { .then(() => eq(add.called, false)); }); - it('tests if initial value is undefined (promise version)', function () { + it('tests if initial value is undefined (promise version)', function() { const add = sinon.spy(); return RA.reduceRightP(add, Promise.resolve(), [1]) @@ -86,36 +109,48 @@ describe('reduceRightP', function () { .then(() => eq(add.called, false)); }); - it('tests iterator wrapped in the promise', function () { - return RA.reduceRightP(R.add, 0, Promise.resolve([1, 2, 3])).then(actual => eq(actual, 6)); + it('tests iterator wrapped in the promise', function() { + return RA.reduceRightP(R.add, 0, Promise.resolve([1, 2, 3])).then(actual => + eq(actual, 6) + ); }); - it('tests iterator containing values and promises', function () { - return RA.reduceRightP(R.add, 0, [1, Promise.resolve(2), 3]).then(actual => eq(actual, 6)); + it('tests iterator containing values and promises', function() { + return RA.reduceRightP(R.add, 0, [1, Promise.resolve(2), 3]).then(actual => + eq(actual, 6) + ); }); - it('tests iterator wrapped in promise containing values and promises', function () { - return RA.reduceRightP(R.add, 0, Promise.resolve([1, Promise.resolve(2), 3])) - .then(actual => eq(actual, 6)); + it('tests iterator wrapped in promise containing values and promises', function() { + return RA.reduceRightP( + R.add, + 0, + Promise.resolve([1, Promise.resolve(2), 3]) + ).then(actual => eq(actual, 6)); }); - it('tests iterator function returning promises', function () { + it('tests iterator function returning promises', function() { return RA.reduceRightP( R.pipe(R.add, Promise.resolve.bind(Promise)), 0, Promise.resolve([1, Promise.resolve(2), 3]) - ) - .then(actual => eq(actual, 6)); + ).then(actual => eq(actual, 6)); }); - it('tests difference between reduceRightP reduceP', function () { + it('tests difference between reduceRightP reduceP', function() { const cat = RA.reduceP(R.concat)(''); const catRight = RA.reduceRightP(R.concat)(''); const catRightFlipped = RA.reduceRightP(R.flip(R.concat))(''); - const testCat = cat(['1', '2', '3', '4']).then(actual => eq(actual, '1234')); - const testCatRight = catRight(['1', '2', '3', '4']).then(actual => eq(actual, '1234')); - const testCatRightFlipped = catRightFlipped(['1', '2', '3', '4']).then(actual => eq(actual, '4321')); + const testCat = cat(['1', '2', '3', '4']).then(actual => + eq(actual, '1234') + ); + const testCatRight = catRight(['1', '2', '3', '4']).then(actual => + eq(actual, '1234') + ); + const testCatRightFlipped = catRightFlipped(['1', '2', '3', '4']).then( + actual => eq(actual, '4321') + ); return Promise.all([testCat, testCatRight, testCatRightFlipped]); }); diff --git a/test/rejectP.js b/test/rejectP.js index eb93302b94..7df9b6f873 100644 --- a/test/rejectP.js +++ b/test/rejectP.js @@ -1,24 +1,24 @@ import * as RA from '../src/index'; import eq from './shared/eq'; +describe('rejectP', function() { + const rejectWithError = () => + Promise.reject(new Error('Expected method to reject.')); -describe('rejectP', function () { - const rejectWithError = () => Promise.reject(new Error('Expected method to reject.')); - - it('tests rejecting with no arguments', function () { + it('tests rejecting with no arguments', function() { return RA.rejectP() .then(rejectWithError) .catch(actual => eq(actual, undefined)); }); - it('tests rejecting thenable values', function () { + it('tests rejecting thenable values', function() { const expected = Promise.resolve(1); return RA.rejectP(expected) .then(rejectWithError) .catch(actual => eq(actual, expected)); }); - it('tests rejecting the only argument', function () { + it('tests rejecting the only argument', function() { const testNumber = RA.rejectP(1) .then(rejectWithError) .catch(actual => eq(actual, 1)); @@ -32,7 +32,6 @@ describe('rejectP', function () { .then(rejectWithError) .catch(actual => eq(actual, { a: 1 })); - return Promise.all([testNumber, testString, testArray, testObj]); }); }); diff --git a/test/renameKeys.js b/test/renameKeys.js index 271e843cce..67b5f16e74 100644 --- a/test/renameKeys.js +++ b/test/renameKeys.js @@ -1,23 +1,31 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('renameKeys', function () { - it('tests renaming object keys', function () { - eq(RA.renameKeys({ key1: 'key2', key2: 'key3' }, { key1: 1, key2: 2 }), { key2: 1, key3: 2 }); +describe('renameKeys', function() { + it('tests renaming object keys', function() { + eq(RA.renameKeys({ key1: 'key2', key2: 'key3' }, { key1: 1, key2: 2 }), { + key2: 1, + key3: 2, + }); }); - it('tests renaming non existing keys', function () { + it('tests renaming non existing keys', function() { eq(RA.renameKeys({ nonExistingKey: 'key2' }, { key1: 1 }), { key1: 1 }); }); - it('tests renaming keys on non object', function () { + it('tests renaming keys on non object', function() { eq(RA.renameKeys({ key1: 'key2' }, null), {}); eq(RA.renameKeys({ key1: 'key2' }, undefined), {}); }); - it('tests currying', function () { - eq(RA.renameKeys({ key1: 'key2', key2: 'key3' }, { key1: 1, key2: 2 }), { key2: 1, key3: 2 }); - eq(RA.renameKeys({ key1: 'key2', key2: 'key3' })({ key1: 1, key2: 2 }), { key2: 1, key3: 2 }); + it('tests currying', function() { + eq(RA.renameKeys({ key1: 'key2', key2: 'key3' }, { key1: 1, key2: 2 }), { + key2: 1, + key3: 2, + }); + eq(RA.renameKeys({ key1: 'key2', key2: 'key3' })({ key1: 1, key2: 2 }), { + key2: 1, + key3: 2, + }); }); }); diff --git a/test/renameKeysWith.js b/test/renameKeysWith.js index db32f11027..60e4c1baf1 100644 --- a/test/renameKeysWith.js +++ b/test/renameKeysWith.js @@ -3,18 +3,23 @@ import { concat } from 'ramda'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('renameKeysWith', function () { - it('tests renaming object keys', function () { - eq(RA.renameKeysWith(concat('a'), { key1: 1, key2: 2 }), { akey1: 1, akey2: 2 }); +describe('renameKeysWith', function() { + it('tests renaming object keys', function() { + eq(RA.renameKeysWith(concat('a'), { key1: 1, key2: 2 }), { + akey1: 1, + akey2: 2, + }); }); - it('tests renaming keys on nil', function () { + it('tests renaming keys on nil', function() { eq(RA.renameKeysWith(concat('a'), null), {}); eq(RA.renameKeysWith(concat('a'), undefined), {}); }); - it('tests currying', function () { - eq(RA.renameKeysWith(concat('a'))({ key1: 1, key2: 2 }), { akey1: 1, akey2: 2 }); + it('tests currying', function() { + eq(RA.renameKeysWith(concat('a'))({ key1: 1, key2: 2 }), { + akey1: 1, + akey2: 2, + }); }); }); diff --git a/test/resolveP.js b/test/resolveP.js index cf39d024d3..970894cedf 100644 --- a/test/resolveP.js +++ b/test/resolveP.js @@ -1,23 +1,21 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('resolveP', function () { - it('tests resolving with no arguments', function () { +describe('resolveP', function() { + it('tests resolving with no arguments', function() { return RA.resolveP().then(actual => eq(actual, undefined)); }); - it('tests resolving thenable values', function () { + it('tests resolving thenable values', function() { return RA.resolveP(Promise.resolve(1)).then(actual => eq(actual, 1)); }); - it('tests resolving the only argument', function () { + it('tests resolving the only argument', function() { const testNumber = RA.resolveP(1); const testString = RA.resolveP('a'); const testArray = RA.resolveP([1, 2, 3]); const testObj = RA.resolveP({ a: 1 }); - return Promise.all([testNumber, testString, testArray, testObj]); }); }); diff --git a/test/seq.js b/test/seq.js index 505e3e7c07..f5e60b4ccb 100644 --- a/test/seq.js +++ b/test/seq.js @@ -2,21 +2,24 @@ import * as R from 'ramda'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('seq', function () { - it('tests calling uncurried', function () { +describe('seq', function() { + it('tests calling uncurried', function() { eq(RA.seq([RA.noop], 3), 3); }); - it('tests calling curried', function () { + it('tests calling curried', function() { eq(RA.seq([RA.noop])(3), 3); }); - it('tests ordered evaluation', function () { + it('tests ordered evaluation', function() { let foo = 2; - const divide = (x) => { foo /= x }; - const multiply = (x) => { foo *= x }; + const divide = x => { + foo /= x; + }; + const multiply = x => { + foo *= x; + }; const seqed = RA.seq([multiply, divide])(3); @@ -24,14 +27,23 @@ describe('seq', function () { eq(foo, 2); }); - it('tests transducing', function () { - const transducer = R.compose(R.map(R.inc), RA.seq([R.inc]), R.filter(RA.isEven)); - const transduced = R.transduce(transducer, R.flip(R.append), [], R.range(0, 10)); + it('tests transducing', function() { + const transducer = R.compose( + R.map(R.inc), + RA.seq([R.inc]), + R.filter(RA.isEven) + ); + const transduced = R.transduce( + transducer, + R.flip(R.append), + [], + R.range(0, 10) + ); eq(transduced, [2, 4, 6, 8, 10]); }); - it('tests an alias', function () { + it('tests an alias', function() { eq(RA.sequencing([RA.noop])(0), 0); }); }); diff --git a/test/shared/Symbol.js b/test/shared/Symbol.js index 54ea3c65f4..3b7b564d26 100644 --- a/test/shared/Symbol.js +++ b/test/shared/Symbol.js @@ -1,2 +1 @@ -export default (typeof Symbol === 'function') ? Symbol : undefined; - +export default (typeof Symbol === 'function' ? Symbol : undefined); diff --git a/test/shared/arguments.js b/test/shared/arguments.js index 05c846bb77..693a76d6c9 100644 --- a/test/shared/arguments.js +++ b/test/shared/arguments.js @@ -1,3 +1,3 @@ -export default (function () { +export default (function() { return arguments; -}()); +})(); diff --git a/test/shared/eq.js b/test/shared/eq.js index 2da28bfcfd..0ce04bfc56 100644 --- a/test/shared/eq.js +++ b/test/shared/eq.js @@ -1,7 +1,6 @@ import assert from 'assert'; import { toString } from 'ramda'; - export default function eq(actual, expected) { assert.strictEqual(arguments.length, 2); assert.strictEqual(toString(actual), toString(expected)); diff --git a/test/sliceFrom.js b/test/sliceFrom.js index 648ed6de4c..443b0ae01b 100644 --- a/test/sliceFrom.js +++ b/test/sliceFrom.js @@ -1,19 +1,20 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('sliceFrom', function () { - it('retrieves the proper sublist of a list', function () { +describe('sliceFrom', function() { + it('retrieves the proper sublist of a list', function() { const list = [8, 6, 7, 5, 3, 0, 9]; eq(RA.sliceFrom(2, list), [7, 5, 3, 0, 9]); }); - it('handles array-like object', function () { - const args = (function () { return arguments }(1, 2, 3, 4, 5)); + it('handles array-like object', function() { + const args = (function() { + return arguments; + })(1, 2, 3, 4, 5); eq(RA.sliceFrom(1, args), [2, 3, 4, 5]); }); - it('can operate on strings', function () { + it('can operate on strings', function() { eq(RA.sliceFrom(0, 'abc'), 'abc'); eq(RA.sliceFrom(1, 'abc'), 'bc'); eq(RA.sliceFrom(2, 'abc'), 'c'); diff --git a/test/sliceTo.js b/test/sliceTo.js index 759f5e2c4d..582ebaeb23 100644 --- a/test/sliceTo.js +++ b/test/sliceTo.js @@ -1,19 +1,20 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('sliceTo', function () { - it('retrieves the proper sublist of a list', function () { +describe('sliceTo', function() { + it('retrieves the proper sublist of a list', function() { const list = [8, 6, 7, 5, 3, 0, 9]; eq(RA.sliceTo(3, list), [8, 6, 7]); }); - it('handles array-like object', function () { - const args = (function () { return arguments }(1, 2, 3, 4, 5)); + it('handles array-like object', function() { + const args = (function() { + return arguments; + })(1, 2, 3, 4, 5); eq(RA.sliceTo(2, args), [1, 2]); }); - it('can operate on strings', function () { + it('can operate on strings', function() { eq(RA.sliceTo(0, 'abc'), ''); eq(RA.sliceTo(1, 'abc'), 'a'); eq(RA.sliceTo(2, 'abc'), 'ab'); diff --git a/test/spreadPath.js b/test/spreadPath.js index 13ca4f8540..bed55644f6 100644 --- a/test/spreadPath.js +++ b/test/spreadPath.js @@ -1,12 +1,11 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('spreadPath', function () { +describe('spreadPath', function() { let path; let obj; - beforeEach(function () { + beforeEach(function() { path = ['b1', 'b2']; obj = { a: 1, @@ -14,15 +13,15 @@ describe('spreadPath', function () { }; }); - it('tests currying', function () { + it('tests currying', function() { const expected = { a: 1, c: 3, d: 4, b1: {} }; eq(RA.spreadPath(path, obj), expected); eq(RA.spreadPath(path)(obj), expected); }); - context('when path leads to non object', function () { - specify('should return object without path', function () { + context('when path leads to non object', function() { + specify('should return object without path', function() { obj = { a: 1, b1: { b2: 999 }, @@ -31,9 +30,12 @@ describe('spreadPath', function () { }); }); - context("when path doesn't exist", function () { - specify('should return object with identical structure as provided object', function () { - eq(RA.spreadPath(['does', 'not', 'exist'], obj), obj); - }); + context("when path doesn't exist", function() { + specify( + 'should return object with identical structure as provided object', + function() { + eq(RA.spreadPath(['does', 'not', 'exist'], obj), obj); + } + ); }); }); diff --git a/test/spreadProp.js b/test/spreadProp.js index 5621a2a9b1..28fb0b86f3 100644 --- a/test/spreadProp.js +++ b/test/spreadProp.js @@ -1,12 +1,11 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('spreadProp', function () { +describe('spreadProp', function() { let prop; let obj; - beforeEach(function () { + beforeEach(function() { prop = 'b'; obj = { a: 1, @@ -14,19 +13,22 @@ describe('spreadProp', function () { }; }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.spreadProp('prop', {}), {}); eq(RA.spreadProp('prop')({}), {}); }); - context("when prop doesn't exist", function () { - specify('should return object with identical structure as provided object', function () { - eq(RA.spreadProp('not_exist', obj), obj); - }); + context("when prop doesn't exist", function() { + specify( + 'should return object with identical structure as provided object', + function() { + eq(RA.spreadProp('not_exist', obj), obj); + } + ); }); - context('when prop leads to non object', function () { - specify('should return object without prop', function () { + context('when prop leads to non object', function() { + specify('should return object without prop', function() { obj = { a: 1, b: 999, @@ -36,8 +38,8 @@ describe('spreadProp', function () { }); }); - context('when prop leads to object with same prop name', function () { - specify('should override existing props on provided object', function () { + context('when prop leads to object with same prop name', function() { + specify('should override existing props on provided object', function() { obj = { a: 1, b: { b: 999, c: 3, d: 4 }, @@ -53,7 +55,7 @@ describe('spreadProp', function () { }); }); - it('should return object with spreaded prop', function () { + it('should return object with spreaded prop', function() { const expected = { a: 1, c: 3, diff --git a/test/stubArray.js b/test/stubArray.js index 648989d6b6..d818049de6 100644 --- a/test/stubArray.js +++ b/test/stubArray.js @@ -2,17 +2,16 @@ import assert from 'assert'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('stubArray', function () { - it('tests `function` that returns empty array', function () { +describe('stubArray', function() { + it('tests `function` that returns empty array', function() { eq(RA.stubArray(), []); eq(RA.stubArray([1]), []); eq(RA.stubArray(new Array()), []); eq(RA.stubArray(1, 2, 3), []); }); - context('when called', function () { - specify('should always return new empty array', function () { + context('when called', function() { + specify('should always return new empty array', function() { const ret1 = RA.stubArray(); const ret2 = RA.stubArray(); assert.notStrictEqual(ret1, ret2); diff --git a/test/stubNull.js b/test/stubNull.js index a9a841eec9..e43c4e056f 100644 --- a/test/stubNull.js +++ b/test/stubNull.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('stubNull', function () { - it('tests `function` that returns `null`', function () { +describe('stubNull', function() { + it('tests `function` that returns `null`', function() { eq(RA.stubNull(), null); eq(RA.stubNull([1]), null); eq(RA.stubNull(new Array()), null); diff --git a/test/stubObj.js b/test/stubObj.js index 6e9f51bda6..eabcca8a6e 100644 --- a/test/stubObj.js +++ b/test/stubObj.js @@ -2,17 +2,16 @@ import assert from 'assert'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('stubObj', function () { - it('tests `function` that returns new empty object', function () { +describe('stubObj', function() { + it('tests `function` that returns new empty object', function() { eq(RA.stubObj(), {}); eq(RA.stubObj([1]), {}); eq(RA.stubObj(new Array()), {}); eq(RA.stubObj(1, 2, 3), {}); }); - context('when called', function () { - specify('should always return new empty object', function () { + context('when called', function() { + specify('should always return new empty object', function() { const ret1 = RA.stubObj(); const ret2 = RA.stubObj(); assert.notStrictEqual(ret1, ret2); diff --git a/test/stubString.js b/test/stubString.js index 70c11d2cfc..1e667f0d20 100644 --- a/test/stubString.js +++ b/test/stubString.js @@ -1,17 +1,16 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('stubString', function () { - it("tests `function` that returns `'''`", function () { +describe('stubString', function() { + it("tests `function` that returns `'''`", function() { eq(RA.stubString(), ''); eq(RA.stubString([1]), ''); eq(RA.stubString(new Array()), ''); eq(RA.stubString(1, 2, 3), ''); }); - context('when called', function () { - specify('should always return empty string', function () { + context('when called', function() { + specify('should always return empty string', function() { const ret1 = RA.stubString(); const ret2 = RA.stubString(); eq(ret1, ret2); diff --git a/test/stubUndefined.js b/test/stubUndefined.js index 4a8b5d35b0..f61e76f815 100644 --- a/test/stubUndefined.js +++ b/test/stubUndefined.js @@ -1,9 +1,8 @@ import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('stubUndefined', function () { - it('tests `function` that returns `undefined`', function () { +describe('stubUndefined', function() { + it('tests `function` that returns `undefined`', function() { eq(RA.stubUndefined(), undefined); eq(RA.stubUndefined([1]), undefined); eq(RA.stubUndefined(new Array()), undefined); diff --git a/test/typescript.js b/test/typescript.js index 8833f262a0..88383fb23d 100644 --- a/test/typescript.js +++ b/test/typescript.js @@ -2,9 +2,8 @@ import * as R from 'ramda'; import path from 'path'; import * as tt from 'typescript-definition-tester'; - -describe('Typescript definitions', function () { - it('should compile against index.d.ts', function (done) { +describe('Typescript definitions', function() { + it('should compile against index.d.ts', function(done) { this.timeout(15000); // give typescript compiler enough time to complete tt.compileDirectory( path.join(__dirname, '..', 'src'), diff --git a/test/viewOr.js b/test/viewOr.js index c110b5807c..6a3344b5f7 100644 --- a/test/viewOr.js +++ b/test/viewOr.js @@ -3,27 +3,26 @@ import { lensIndex, lensProp } from 'ramda'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('viewOr', function () { - it('tests "view"', function () { +describe('viewOr', function() { + it('tests "view"', function() { eq(RA.viewOr('foo', lensProp('bar'), { bar: 'foobar' }), 'foobar'); eq(RA.viewOr('foo', lensProp('bar'), { bar: false }), false); eq(RA.viewOr('foo', lensProp('bar'), { bar: 1 }), 1); }); - it('tests found "view" with default value fallback', function () { + it('tests found "view" with default value fallback', function() { eq(RA.viewOr('foo', lensProp('bar'), { bar: undefined }), 'foo'); eq(RA.viewOr('foo', lensProp('bar'), { bar: null }), 'foo'); eq(RA.viewOr('foo', lensProp('bar'), { bar: NaN }), 'foo'); }); - it('tests default value', function () { + it('tests default value', function() { eq(RA.viewOr('foo', lensProp('bar'), {}), 'foo'); eq(RA.viewOr('foo', lensIndex(11), []), 'foo'); eq(RA.viewOr('foo', lensIndex(11), {}), 'foo'); }); - it('tests currying', function () { + it('tests currying', function() { eq(RA.viewOr('foo')(lensProp('bar'))({}), 'foo'); eq(RA.viewOr('foo', lensProp('bar'))({}), 'foo'); eq(RA.viewOr('foo')(lensProp('bar'), {}), 'foo'); diff --git a/test/weave.js b/test/weave.js index 68722ac79e..5fc5050285 100644 --- a/test/weave.js +++ b/test/weave.js @@ -4,14 +4,14 @@ import { Reader as reader } from 'monet'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('weave', function () { +describe('weave', function() { const unaryReader = a => reader(config => config + a); const binaryReader = (a, b) => reader(config => config + a + b); const variadicReader = (...args) => reader(config => sum(args) + config); - const mixedReader = (a, b, ...args) => reader(config => sum(args.concat(a, b, config))); + const mixedReader = (a, b, ...args) => + reader(config => sum(args.concat(a, b, config))); - it('tests weaving', function () { + it('tests weaving', function() { const wunaryReader = RA.weave(unaryReader, 1); const wbinaryReader = RA.weave(binaryReader, 1); @@ -19,7 +19,7 @@ describe('weave', function () { eq(wbinaryReader(2, 3), 6); }); - it('tests currying', function () { + it('tests currying', function() { const wbinaryReader1 = RA.weave(binaryReader, 1); const wbinaryReader2 = RA.weave(binaryReader)(1); @@ -27,40 +27,40 @@ describe('weave', function () { eq(wbinaryReader2(2, 3), 6); }); - it('tests auto-currying on fixed function signature', function () { + it('tests auto-currying on fixed function signature', function() { const wbinaryReader = RA.weave(binaryReader, 1); eq(wbinaryReader(2, 3), 6); eq(wbinaryReader(2)(3), 6); }); - it('tests auto-currying on curried fixed function signature', function () { + it('tests auto-currying on curried fixed function signature', function() { const wbinaryReader = RA.weave(curry(binaryReader), 1); eq(wbinaryReader(2, 3), 6); eq(wbinaryReader(2)(3), 6); }); - it('tests auto-currying on variadic function signature', function () { + it('tests auto-currying on variadic function signature', function() { const wvariadicReader = RA.weave(variadicReader, 1); eq(wvariadicReader(1, 2, 3), 7); }); - it('tests auto-currying on curried variadic function signature', function () { + it('tests auto-currying on curried variadic function signature', function() { const wvariadicReader = RA.weave(curry(variadicReader), 1); eq(wvariadicReader(1, 2, 3), 7); }); - it('tests auto-currying on mixed function signature', function () { + it('tests auto-currying on mixed function signature', function() { const wmixedReader = RA.weave(mixedReader, 1); eq(wmixedReader(2, 3, 4), 10); eq(wmixedReader(2)(3, 4), 10); }); - it('tests auto-currying on curried mixed function signature', function () { + it('tests auto-currying on curried mixed function signature', function() { const wmixedReader = RA.weave(curry(mixedReader), 1); eq(wmixedReader(2, 3, 4), 10); diff --git a/test/weaveLazy.js b/test/weaveLazy.js index de439f98dc..5a3829f90b 100644 --- a/test/weaveLazy.js +++ b/test/weaveLazy.js @@ -4,14 +4,14 @@ import { Reader as reader } from 'monet'; import * as RA from '../src/index'; import eq from './shared/eq'; - -describe('weaveLazy', function () { +describe('weaveLazy', function() { const unaryReader = a => reader(config => config + a); const binaryReader = (a, b) => reader(config => config + a + b); const variadicReader = (...args) => reader(config => sum(args) + config); - const mixedReader = (a, b, ...args) => reader(config => sum(args.concat(a, b, config))); + const mixedReader = (a, b, ...args) => + reader(config => sum(args.concat(a, b, config))); - it('tests weaving', function () { + it('tests weaving', function() { const wunaryReader = RA.weaveLazy(unaryReader, always(1)); const wbinaryReader = RA.weaveLazy(binaryReader, always(1)); @@ -19,7 +19,7 @@ describe('weaveLazy', function () { eq(wbinaryReader(2, 3), 6); }); - it('tests currying', function () { + it('tests currying', function() { const wbinaryReader1 = RA.weaveLazy(binaryReader, always(1)); const wbinaryReader2 = RA.weaveLazy(binaryReader)(always(1)); @@ -27,40 +27,40 @@ describe('weaveLazy', function () { eq(wbinaryReader2(2, 3), 6); }); - it('tests auto-currying on fixed function signature', function () { + it('tests auto-currying on fixed function signature', function() { const wbinaryReader = RA.weaveLazy(binaryReader, always(1)); eq(wbinaryReader(2, 3), 6); eq(wbinaryReader(2)(3), 6); }); - it('tests auto-currying on curried fixed function signature', function () { + it('tests auto-currying on curried fixed function signature', function() { const wbinaryReader = RA.weaveLazy(curry(binaryReader), always(1)); eq(wbinaryReader(2, 3), 6); eq(wbinaryReader(2)(3), 6); }); - it('tests auto-currying on variadic function signature', function () { + it('tests auto-currying on variadic function signature', function() { const wvariadicReader = RA.weaveLazy(variadicReader, always(1)); eq(wvariadicReader(1, 2, 3), 7); }); - it('tests auto-currying on curried variadic function signature', function () { + it('tests auto-currying on curried variadic function signature', function() { const wvariadicReader = RA.weaveLazy(curry(variadicReader), always(1)); eq(wvariadicReader(1, 2, 3), 7); }); - it('tests auto-currying on mixed function signature', function () { + it('tests auto-currying on mixed function signature', function() { const wmixedReader = RA.weaveLazy(mixedReader, always(1)); eq(wmixedReader(2, 3, 4), 10); eq(wmixedReader(2)(3, 4), 10); }); - it('tests auto-currying on curried mixed function signature', function () { + it('tests auto-currying on curried mixed function signature', function() { const wmixedReader = RA.weaveLazy(curry(mixedReader), always(1)); eq(wmixedReader(2, 3, 4), 10); diff --git a/tslint.json b/tslint.json index aa95ffbbfc..345e38b174 100644 --- a/tslint.json +++ b/tslint.json @@ -1,7 +1,8 @@ { "defaultSeverity": "error", "extends": [ - "tslint:recommended" + "tslint:recommended", + "tslint-config-prettier" ], "jsRules": {}, "rules": {