Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

chosen ajax options are allowed to be undefined.

  • Loading branch information...
commit a335d3c42f71452799effbe5636d2888dc6e8eb9 1 parent d7c3ae3
@ksykulev ksykulev authored
View
2  README.md
@@ -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
-------------
View
1  chosen.ajaxaddition.jquery.js
@@ -126,6 +126,7 @@
}
};
//set loading image
+ options || (options = {});
if ('loadingImg' in options) {
loadingImg = options.loadingImg;
}
View
1  example/chosen.ajaxaddition.jquery.js
@@ -126,6 +126,7 @@
}
};
//set loading image
+ options || (options = {});
if ('loadingImg' in options) {
loadingImg = options.loadingImg;
}
View
16 test/main.js
@@ -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,
Please sign in to comment.
Something went wrong with that request. Please try again.