vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.9 KiB

  1. var assert = require('assert');
  2. var vis = require('../dist/vis');
  3. var jsdom = require('mocha-jsdom')
  4. var moment = vis.moment;
  5. var timeline = vis.timeline;
  6. var TimeStep = timeline.TimeStep;
  7. var TestSupport = require('./TestSupport');
  8. describe('TimeStep', function () {
  9. jsdom();
  10. it('should work with just start and end dates', function () {
  11. var timestep = new TimeStep(new Date(2017, 3, 3), new Date(2017, 3, 5));
  12. assert.equal(timestep.autoScale, true, "should autoscale if scale not specified");
  13. assert.equal(timestep.scale, "day", "should default to day scale if scale not specified");
  14. assert.equal(timestep.step, 1, "should default to 1 day step if scale not specified");
  15. });
  16. it('should work with specified scale (just under 1 second)', function () {
  17. var timestep = new TimeStep(new Date(2017, 3, 3), new Date(2017, 3, 5), 999);
  18. assert.equal(timestep.scale, "second", "should have right scale");
  19. assert.equal(timestep.step, 1, "should have right step size");
  20. });
  21. // TODO: check this - maybe should work for 1000?
  22. it('should work with specified scale (1 second)', function () {
  23. var timestep = new TimeStep(new Date(2017, 3, 3), new Date(2017, 3, 5), 1001);
  24. assert.equal(timestep.scale, "second", "should have right scale");
  25. assert.equal(timestep.step, 5, "should have right step size");
  26. });
  27. it('should work with specified scale (2 seconds)', function () {
  28. var timestep = new TimeStep(new Date(2017, 3, 3), new Date(2017, 3, 5), 2000);
  29. assert.equal(timestep.scale, "second", "should have right scale");
  30. assert.equal(timestep.step, 5, "should have right step size");
  31. });
  32. it('should work with specified scale (5 seconds)', function () {
  33. var timestep = new TimeStep(new Date(2017, 3, 3), new Date(2017, 3, 5), 5001);
  34. assert.equal(timestep.scale, "second", "should have right scale");
  35. assert.equal(timestep.step, 10, "should have right step size");
  36. });
  37. });