Skip to content
Permalink
Browse files

Spinner: Fix value option initalization

  • Loading branch information...
jzaefferer committed Oct 25, 2010
1 parent 1be2a79 commit 299d5c88b8bd60b23c03f73fd0dc8bf4d9cfb2a2
@@ -34,6 +34,7 @@ <h2 id="qunit-userAgent"></h2>

<div id="qunit-fixture">
<input id="spin">
<input id="spin2" value="2">
</div>

</body>
@@ -12,7 +12,7 @@ var spinner_defaults = {
numberformat: "n",
page: 5,
step: null,
value: 0
value: null
};

commonWidgetTests('spinner', { defaults: spinner_defaults });
@@ -157,15 +157,30 @@ test("step", function() {

});

test("value", function() {
expect(2);

el = $('#spin').spinner({ value: 100 });

test("value, default, specified in markup", function() {
var el = $('#spin2').spinner();
equals(el.val(), 2, "starting value");
});

test("value, default, nothing specified", function() {
var el = $('#spin').spinner();
equals(el.val(), 0, "starting value");
});

test("value, override", function() {
var el = $('#spin').spinner({ value: 100 });
equals(el.val(), 100, "starting value");

});

test("value, override markup", function() {
var el = $('#spin2').spinner({ value: 100 });
equals(el.val(), 100, "starting value");
});

test("value, override later", function() {
var el = $('#spin').spinner();
equals(el.val(), 0, "starting value");
el.spinner('option', 'value', 1000);

equals(el.val(), 1000, "value option changed and set as current value");
});

@@ -29,11 +29,11 @@ $.widget('ui.spinner', {
numberformat: "n",
page: 5,
step: null,
value: 0
value: null
},

_create: function() {
this.value(this.element.val() || this.options.value);
this.value(this.options.value !== null ? this.options.value : this.element.val());
this._draw();
this._mousewheel();
this._aria();

0 comments on commit 299d5c8

Please sign in to comment.
You can’t perform that action at this time.