Skip to content

Conversation

jmaguirrei
Copy link

Section 6 - Adding Unit Tests modified to make testing more flexible.

Synchronous tests like:

// Assert that the getANumber function is returning 1
unit['helpers.getANumber should return 1'] = function(/* done */){
  var val = helpers.getANumber();
  assert.equal(val, 1);
  // done();
};

Does not require callback function (done) anymore.

On the other hand, async tests still works when callback function is passed:

// Logs.list should callback an array and a false error
unit['logs.list should callback a false error and an array of log names'] = function(done){
  logs.list(true,function(err,logFileNames){
      assert.equal(err, false);
      assert.ok(logFileNames instanceof Array);
      assert.ok(logFileNames.length > 1);
      done();
  });
};

So test runner now is more flexible and reduces boilerplate for sync functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant