Giter VIP home page Giter VIP logo

lodown's Introduction

lodown

An npm functional programming library project

  1. Fork this repository to your own GitHub account.

  2. Clone your forked version of the lodown repository to a new Cloud9 workspace or locally if you prefer.

  3. To create a package.json configuration file for our lodown library, from the command-line, run the command:

     npm init
    
  4. IMPORTANT CONFIGURATION: Fill in the prompts with your own details:

    1. When asked for test command, enter:

      istanbul cover _mocha -- test/ -R spec

    2. When asked for your git repository, you will probably be given the correct url as the default, so just select this by pressing return, otherwise, provide your forked GitHub repository's url.

  5. Install the required test libraries by running the following command:

     npm install i -D mocha chai sinon istanbul
    
  6. Write your tests in the file test/index.spec.js. Check out the chai api for and be careful when asserting/expecting against complex types - you'll have to make use of the .eql api, and not .equal. For example:

     expect(lodown.filter([1, 2, 3], function(value) { return value > 2; } )).to.eql([3]);
    
  7. Implement your library in the file index.js. Remember that index.js is a Node.js module, so you must export your API using, for example:

     module.exports.each = each;
    
  8. To run your tests, run the following command:

     npm test
    
  9. Check the console output for passes and failures.

  10. Preview (Cloud9) or open the file at coverage/lcov-report/index.html for your coverage report. Make certain all lines of code are traversed in your tests!

Solve

Using the file at test/fixtures/customers.json, and utilizing your lodown library, write functions that take the Array of customers and return the following:

  1. how many males, how many females
  2. oldest customer, youngest customer
  3. average balance
  4. how many customer's names begin with some letter
  5. how many customer's friend's names begin with some letter
  6. how many customers are friends
  7. how many customers have friends in common
  8. most common tags

Resources:

Docs

  1. https://mochajs.org
  2. http://chaijs.com/api/bdd/
  3. http://sinonjs.org/docs/#spies-api

Reading

  1. http://marcofranssen.nl/using-mocha-chai-sinon-to-test-node-js/
  2. http://stackoverflow.com/questions/19298118/what-is-the-role-of-describe-in-mocha
  3. http://www.vapidspace.com/coding/2014/10/29/code-coverage-metrics-with-mocha-and-istanbul/

Quick Videos

  1. https://egghead.io/lessons/javascript-how-to-write-a-javascript-library-setting-up-unit-testing-with-mocha-and-chai
  2. https://egghead.io/lessons/javascript-how-to-write-a-javascript-library-unit-testing-with-mocha-and-chai

lodown's People

Contributors

jfraboni avatar

Watchers

James Cloos avatar Harvey Sanders avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.