Skip to content

Commit

Permalink
test revealing the issue of sliders, that are initially hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
MaZderMind committed Mar 8, 2016
1 parent 282253e commit 739081c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/specs/PublicMethodsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,38 @@ describe("Public Method Tests", function() {
expect(tooltipMarginLeft).toBeGreaterThan(0);
});

it("relayout: if slider is not displayed on initialization and then displayed later on, relayout() will re-adjust the tick label width", function() {
// Setup
testSlider = new Slider("#relayoutSliderInputTickLabels", {
id: "relayoutSliderTickLabels",
min: 0,
max: 10,
ticks: [0, 5, 10],
ticks_labels: ['low', 'mid', 'high'],
value: 5
});

var $ticks = $('#relayoutSliderTickLabels').find('.slider-tick-label');

// Tick-Width should be 0 on slider intialization
var i, $tick;
for (i = 0; i < $ticks.length; i++) {
$tick = $($ticks[i]);
expect( parseInt($tick.css('width')) ).toBe(0);
}

// Show slider and call relayout()
$('#relayoutSliderContainerTickLabels').css('display', 'block');
testSlider.relayout();
$('#relayoutSliderContainerTickLabels').css('display', 'none');

// Tick-Width should re-adjust to be > 0
for (i = 0; i < $ticks.length; i++) {
$tick = $($ticks[i]);
expect( parseInt($tick.css('width')) ).toBeGreaterThan(0);
}
});

afterEach(function() {
if(testSlider) {
if(testSlider instanceof jQuery) { testSlider.slider('destroy'); }
Expand Down
4 changes: 4 additions & 0 deletions tpl/SpecRunner.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
<input id="relayoutSliderInput" type="text"/>
</div>

<div id="relayoutSliderContainerTickLabels" style="display: none">
<input id="relayoutSliderInputTickLabels" type="text"/>
</div>

<div id="scrollable-div">
<p>just a row</p>
<p>just a row</p>
Expand Down

0 comments on commit 739081c

Please sign in to comment.