Permalink
Browse files

chosen ajax options are allowed to be undefined.

  • Loading branch information...
1 parent d7c3ae3 commit a335d3c42f71452799effbe5636d2888dc6e8eb9 @ksykulev committed Feb 6, 2013
Showing with 14 additions and 6 deletions.
  1. +1 −1 README.md
  2. +1 −0 chosen.ajaxaddition.jquery.js
  3. +1 −0 example/chosen.ajaxaddition.jquery.js
  4. +11 −5 test/main.js
View
@@ -21,7 +21,7 @@ Critical Todos:
Some More Todos:
* Move q to higher scope the server doesn't have to pass it back in request
-* Add check for ajaxChosenOptions being undefined
+* ~~Add check for ajaxChosenOptions being undefined
Example Usage
-------------
@@ -126,6 +126,7 @@
}
};
//set loading image
+ options || (options = {});
if ('loadingImg' in options) {
loadingImg = options.loadingImg;
}
@@ -126,6 +126,7 @@
}
};
//set loading image
+ options || (options = {});
if ('loadingImg' in options) {
loadingImg = options.loadingImg;
}
View
@@ -76,6 +76,12 @@ describe('chosen.ajaxaddition', function(){
this.server.restore();
this.clock.restore();
});
+ it('should initial chosen with empty options', function(){
+ var mock = sinon.mock($.fn);
+ mock.expects('chosen').once();
+ $('select', space).ajaxChosen({});
+ expect(mock.verify()).to.be.true;
+ });
it('should use loadingImg while processing', function(){
var chosen,
input,
@@ -563,18 +569,18 @@ describe('chosen.ajaxaddition', function(){
//discard first response keep newly typed word and ajax chosen should still look like it's still processing
expect(input.val()).to.equal('banana');
- expect(input.css('background-image')).to.match(/loading\.gif/i);
+ expect(input.prop('style')['background']).to.match(/loading\.gif/i);
//the rest of the clock ticks down so we should now fire off the second request
this.clock.tick(400);
expect(this.requests).to.have.length(2);
expect(input.val()).to.equal('banana');
//yup still waiting for the server to respond
- expect(input.css('background-image')).to.match(/loading\.gif/i);
+ expect(input.prop('style')['background']).to.match(/loading\.gif/i);
//response 2 comes back and banana is selected
this.requests[1].respond(200, { "Content-Type": "application/json" }, '{ "q": "banana", "results": [{"id":1, "text":"banana bunch"}]}');
expect(input.val()).to.equal('banana');
- expect(input.css('background-image')).to.not.match(/loading\.gif/i);
+ expect(input.prop('style')['background']).to.not.match(/loading\.gif/i);
});
it('in order', function(){
var chosen,
@@ -613,12 +619,12 @@ describe('chosen.ajaxaddition', function(){
//discard first response keep newly typed word and ajax chosen should still look like it's still processing
expect(input.val()).to.equal('banana');
- expect(input.css('background-image')).to.match(/loading\.gif/i);
+ expect(input.prop('style')['background']).to.match(/loading\.gif/i);
//response 2 comes back and banana is selected
this.requests[1].respond(200, { "Content-Type": "application/json" }, '{ "q": "banana", "results": [{"id":1, "text":"banana bunch"}]}');
expect(input.val()).to.equal('banana');
- expect(input.css('background-image')).to.not.match(/loading\.gif/i);
+ expect(input.prop('style')['background']).to.not.match(/loading\.gif/i);
});
it('out of order', function(){
var chosen,

0 comments on commit a335d3c

Please sign in to comment.