I made a small library for which I want to write the test cases. Please note, this is the first time I am going to write unit test cases :)
My library is a small charting library using d3.js to plot a chart. It's a 200 line code written using module patter like this below (just a sample):
var graph = (function() {
var a, b, c;
function x() {
//uses a
}
function y() {
uses a, b and possibly calls x
}
function plotChart() {
//uses c;
},
function plotAxis() {
//uses a,b
}
function validate() {
//validates values
}
return {
createChart: function(options) {
//calls validate,
//calls plotChart
//calls plotaxis
.
.
.
.
}
}
What is the best way to start with unit testing this kinda code. Most of the functions like a, b,c, plotGraph, plotAxis etc are private functions which are not exposed to outside world.
Plus, is mocha is a good choice? My aim is to get a taste of unit testing and then gain experience by delving deeper. Please suggest.
Aucun commentaire:
Enregistrer un commentaire