HEX
Server: Apache
System: Linux webd004.cluster130.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User: frenchy (106757)
PHP: 7.4.33
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/f/r/e/frenchy/www/french-american.org/current/node_modules/timespan/test/helpers.js
/*
 * helpers.js: Tests helpers for the TimeSpan module.
 *
 * (C) Charlie Robbins
 * MIT LICENSE
 *
 */

var assert = require('assert'),
    timeSpan = require('../lib/time-span')
 
function capitalize(str) {
  return str.charAt(0).toUpperCase() + str.slice(1);
}

var helpers = exports,
    components = ['milliseconds', 'seconds', 'minutes', 'hours', 'days'];

//
// Tests all of the factory methods for the `TimeSpan` object:
// `fromMilliseconds`, `fromSeconds`, etc.
//
exports.testFactories = function (num) {
  var context = {};
  
  components.forEach(function (component) {
    var method = 'from' + capitalize(component);
    
    context['the ' + method + '() method'] = function () {
      var value = timeSpan[method](num);
      assert.equal(value[component], num);
    }
  });
  
  return context;
};