jquery.flot.symbol.Test.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* eslint-disable */
  2. /* global $, describe, it, xit, xdescribe, after, afterEach, expect*/
  3. describe("flot symbol plugin", function() {
  4. var placeholder, plot;
  5. var options;
  6. beforeEach(function() {
  7. options = {
  8. series: {
  9. shadowSize: 0, // don't draw shadows
  10. lines: { show: false},
  11. points: { show: true, fill: false, symbol: 'circle' }
  12. }
  13. };
  14. placeholder = setFixtures('<div id="test-container" style="width: 600px;height: 400px">')
  15. .find('#test-container');
  16. });
  17. it ('provides a list of draw symbols functions', function () {
  18. plot = $.plot(placeholder, [[]], options);
  19. expect(typeof plot.drawSymbol).toBe('object');
  20. })
  21. var shapes = ['square', 'rectangle', 'diamond', 'triangle', 'cross', 'ellipse', 'plus'];
  22. shapes.forEach(function (shape) {
  23. it('should provide a way to draw ' + shape + ' shapes', function () {
  24. plot = $.plot(placeholder, [[]], options);
  25. expect(typeof plot.drawSymbol[shape]).toBe('function')
  26. })
  27. })
  28. shapes.forEach(function (shape) {
  29. it ('' + shape + ' method should be called when the point shape is ' + shape, function () {
  30. options.series.points.symbol = shape;
  31. plot = $.plot(placeholder, [[]], options);
  32. spyOn(plot.drawSymbol, shape).and.callThrough();
  33. plot.setData([[[0, 1], [1, 2]]]);
  34. plot.setupGrid(true);
  35. plot.draw();
  36. expect(plot.drawSymbol[shape]).toHaveBeenCalledTimes(2);
  37. });
  38. });
  39. });