RtlOptionsSpec.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. describe("RTL Tests", function() {
  2. var testSlider;
  3. afterEach(function() {
  4. if(testSlider) {
  5. testSlider.destroy();
  6. testSlider = null;
  7. }
  8. });
  9. describe("rtl slider tests", function() {
  10. it("should be rtl by default inside an rtl wrapper", function() {
  11. testSlider = new Slider("#rtlSlider");
  12. var dirIsRtl = $("#rtlSlider").siblings().is(".slider-rtl");
  13. expect(dirIsRtl).toBeTruthy();
  14. });
  15. it("rtl to false inside an rtl wrapper", function() {
  16. testSlider = new Slider("#rtlSlider", {
  17. rtl: false
  18. });
  19. var dirIsRtl = $("#rtlSlider").siblings().is(".slider-rtl");
  20. expect(dirIsRtl).not.toBeTruthy();
  21. });
  22. it("rtl to true inside an ltr wrapper", function() {
  23. testSlider = new Slider("#testSlider1", {
  24. rtl: true
  25. });
  26. var dirIsRtl = $("#testSlider1").siblings().is(".slider-rtl");
  27. expect(dirIsRtl).toBeTruthy();
  28. });
  29. it("slider use inversed left and right inline style", function() {
  30. testSlider = new Slider("#rtlSlider", {
  31. min: 0,
  32. max: 10,
  33. value: 5
  34. });
  35. var sliderTrackLowRight=$("#rtlSlider").siblings(".slider-rtl").children("div.slider-track").children("div.slider-track-low").css("right");
  36. var sliderSelectionRight=$("#rtlSlider").siblings(".slider-rtl").children("div.slider-track").children("div.slider-selection").css("right");
  37. var sliderTrackHighLeft=$("#rtlSlider").siblings(".slider-rtl").children("div.slider-track").children("div.slider-track-high").css("left");
  38. expect(sliderTrackLowRight).toBe("0px");
  39. expect(sliderSelectionRight).toBe("0%");
  40. expect(sliderTrackHighLeft).toBe("0px");
  41. });
  42. it("tooltip position must be inversed in vertical", function() {
  43. testSlider = new Slider("#rtlSlider", {
  44. orientation: "vertical",
  45. });
  46. var mainTooltipHasClassLeft = testSlider.tooltip.classList.contains("left");
  47. expect(mainTooltipHasClassLeft).toBeTruthy();
  48. expect(testSlider.tooltip.style.right).toBe("100%");
  49. });
  50. it("tooltip position can be forced in vertical", function() {
  51. testSlider = new Slider("#rtlSlider", {
  52. orientation: "vertical",
  53. tooltip_position: "right",
  54. });
  55. var mainTooltipHasClassRight = testSlider.tooltip.classList.contains("right");
  56. expect(mainTooltipHasClassRight).toBeTruthy();
  57. expect(testSlider.tooltip.style.left).toBe("100%");
  58. });
  59. });
  60. }); // End of spec