Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR to improve tests by requiring callback fn only for async tests #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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