TooltipSplitOptionSpec.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. *************************
  3. tooltip_split Option Test
  4. *************************
  5. This spec tests if tooltip_main, tooltip_min and tooltip_max
  6. behave correctly when tooltip_split option is set to true or false.
  7. */
  8. describe("'tooltip_split' Option tests", function() {
  9. var testSlider, sliderId = "tooltipedSlider",
  10. $slider, $tooltipMain, $tooltipMin, $tooltipMax,
  11. sliderOptions = {id: sliderId, value: [0, 10], tooltip: "always"}; // for the sake of testing, always display the tooltip
  12. describe("When 'tooltip_split' is false", function() {
  13. beforeEach(function() {
  14. testSlider = $("#testSlider1").slider($.extend(sliderOptions, {tooltip_split: false}));
  15. $slider = $("#"+sliderId);
  16. $tooltipMain = $slider.find(".tooltip-main");
  17. $tooltipMin = $slider.find(".tooltip-min");
  18. $tooltipMax = $slider.find(".tooltip-max");
  19. });
  20. it("should have `tooltip-main` displayed with `in` class", function() {
  21. expect($tooltipMain.css("display")).not.toBe("none");
  22. expect($tooltipMain.hasClass("in")).toBeTruthy();
  23. });
  24. it("should have `tooltip-min, tooltip-max` not displayed", function() {
  25. expect($tooltipMin.css("display")).toBe("none");
  26. expect($tooltipMin.hasClass("in")).toBeFalsy();
  27. expect($tooltipMax.css("display")).toBe("none");
  28. expect($tooltipMax.hasClass("in")).toBeFalsy();
  29. });
  30. });
  31. describe("When 'tooltip_split' is true", function() {
  32. beforeEach(function() {
  33. testSlider = $("#testSlider1").slider($.extend(sliderOptions, {tooltip_split: true}));
  34. $slider = $("#"+sliderId);
  35. $tooltipMain = $slider.find(".tooltip-main");
  36. $tooltipMin = $slider.find(".tooltip-min");
  37. $tooltipMax = $slider.find(".tooltip-max");
  38. });
  39. it("should have `tooltip-min, tooltip-max` displayed with `in` class", function() {
  40. expect($tooltipMin.css("display")).not.toBe("none");
  41. expect($tooltipMin.hasClass("in")).toBeTruthy();
  42. expect($tooltipMax.css("display")).not.toBe("none");
  43. expect($tooltipMax.hasClass("in")).toBeTruthy();
  44. });
  45. it("should have `tooltip-main` not displayed", function() {
  46. expect($tooltipMain.css("display")).toBe("none");
  47. expect($tooltipMain.hasClass("in")).toBeFalsy();
  48. });
  49. it("should be aligned above the handle on init if set to 'top'", function() {
  50. expect($tooltipMin.hasClass("top")).toBeTruthy();
  51. expect($tooltipMax.hasClass("top")).toBeTruthy();
  52. });
  53. });
  54. afterEach(function() {
  55. if(testSlider) {
  56. testSlider.slider('destroy');
  57. testSlider = null;
  58. }
  59. });
  60. });