Skip to content

Commit

Permalink
Lodash 4 compatibility (#585)
Browse files Browse the repository at this point in the history
Resolves #561. Summary of changes:

 - It is now possible to run the entire test suite with Lodash instead of Underscore by passing the `--lodash` option to `karma start`. Still runs with Underscore by default. (Tip for Yarn users: you can just do `yarn test --lodash`).
 - Feature detection of `_.any` is used to determine whether the `_` factory argument is Underscore or Lodash. In the latter case, some aliases are created on `_` in order to keep the code changes to a minimum.
 - Everywhere a third `context` argument was passed to functions like `_.each` and `_.map`, `_.bind` is now used instead.
 - Travis build runs both the Underscore variant and the Lodash variant of the test suite (and both pass).
 - Travis config updated to use Node version 8 instead of 4, in order to resolve compatibility issues with the force-updated `npm` command line program.
 - `index.html` updated to reflect that Lodash works, too.

Note on the `CONTRIBUTING.md` and the `.editorconfig`: these files tell me that JavaScript files should be two-space indented, but the JavaScript files I edited were already tab-indented. I decided to go with the existing practice.
  • Loading branch information
jgonggrijp authored and bpatram committed Feb 4, 2019
1 parent 1ee7dc0 commit 4e2f5c0
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 61 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
language: node_js
node_js:
- "4"
- "8"
before_install:
- npm install -g npm
- npm install -g karma-cli
- npm install -g karma-cli@1
script:
- npm test
- karma start --single-run --browsers PhantomJS --lodash
sudo: false
cache:
directories:
Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Before you submit your Pull Request ensure the following things are true for you
- How to setup [ESLint](http://eslint.org/docs/user-guide/integrations)
2. Your changes are branched off of `master`
3. You have added a test case for your changes or updated an existing test case
4. All test cases are passing
4. All test cases are passing, both with Underscore and Lodash

# Running Unit Tests
You can run tests using PhantomJS (headless) or a web browser (Chrome)
Expand All @@ -29,3 +29,5 @@ You can run tests using PhantomJS (headless) or a web browser (Chrome)
- To run tests in a browser:
1. Run `karma start --single-run`
2. Open Chrome and connect to the url it outputs

You can test with Lodash instead of Underscore by passing the `--lodash` option to `karma start` or `yarn test`.
Loading

0 comments on commit 4e2f5c0

Please sign in to comment.