testUtils.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var Utils = require('../../lib/util/utils.js');
  2. module.exports = {
  3. testFormatElapsedTime : function(client) {
  4. var test = client.assert;
  5. var resultMs = Utils.formatElapsedTime(999);
  6. test.equal(resultMs, '999ms');
  7. var resultSec = Utils.formatElapsedTime(1999);
  8. test.equal(resultSec, '1.999s');
  9. var resultMin = Utils.formatElapsedTime(122299, true);
  10. test.equal(resultMin, '2m 2s / 122299ms');
  11. },
  12. testMakeFnAsync : function(client) {
  13. function asynFn(done) {
  14. done();
  15. }
  16. function syncFn() {}
  17. var test = client.assert;
  18. test.equal(Utils.makeFnAsync(1, asynFn), asynFn);
  19. var convertedFn = Utils.makeFnAsync(1, syncFn);
  20. convertedFn(function() {
  21. test.ok('converted fn called');
  22. });
  23. },
  24. testGetTestSuiteName : function(client) {
  25. var test = client.assert;
  26. test.equal(Utils.getTestSuiteName('test-case-one'), 'Test Case One');
  27. test.equal(Utils.getTestSuiteName('test_case_two'), 'Test Case Two');
  28. test.equal(Utils.getTestSuiteName('test.case.one'), 'Test Case One');
  29. test.equal(Utils.getTestSuiteName('testCaseOne'), 'Test Case One');
  30. }
  31. };