jquery.flot.flatdata.Test.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* eslint-disable */
  2. /* global $, describe, it, xit, xdescribe, after, afterEach, expect*/
  3. describe("flatdata plugin", function() {
  4. var placeholder, plot;
  5. var options = {
  6. series: {
  7. shadowSize: 0, // don't draw shadows
  8. lines: { show: false},
  9. points: { show: true, fill: false, symbol: 'circle' }
  10. }
  11. };
  12. beforeEach(function() {
  13. placeholder = setFixtures('<div id="test-container" style="width: 600px;height: 400px">')
  14. .find('#test-container');
  15. });
  16. it('registers an init hook', function () {
  17. var flatdata = $.plot.plugins.find(function(plugin) { return plugin.name === 'flatdata'; });
  18. expect(flatdata).toBeTruthy();
  19. expect(flatdata.init).toBeTruthy();
  20. });
  21. it('writes the x and y values into a single 1D array when the plugin is activated', function () {
  22. options.series.flatdata = true;
  23. plot = $.plot(placeholder, [[10, 20, 30]], options);
  24. var points = plot.getData()[0].datapoints.points;
  25. expect(points[0]).toBe(0);
  26. expect(points[1]).toBe(10);
  27. expect(points[2]).toBe(1);
  28. expect(points[3]).toBe(20);
  29. expect(points[4]).toBe(2);
  30. expect(points[5]).toBe(30);
  31. });
  32. it('works for empty data', function () {
  33. options.series.flatdata = true;
  34. plot = $.plot(placeholder, [[]], options);
  35. var datapoints = plot.getData()[0].datapoints;
  36. expect(datapoints.points.length).toBe(0);
  37. });
  38. });