don't use the deprecated ".selector" method

This commit is contained in:
cmrd Senya 2016-12-10 00:19:47 +02:00 committed by Steffen van Bergerem
parent a479db1c96
commit f36a4cd1f5
No known key found for this signature in database
GPG key ID: 315C9787D548DC6B
4 changed files with 27 additions and 15 deletions

View file

@ -41,18 +41,23 @@ describe("app", function() {
}); });
describe("setupForms", function() { describe("setupForms", function() {
beforeEach(function() {
spec.content().append("<textarea/> <input/>");
});
it("calls jQuery.placeholder() for inputs", function() { it("calls jQuery.placeholder() for inputs", function() {
spyOn($.fn, "placeholder"); spyOn($.fn, "placeholder");
app.setupForms(); app.setupForms();
expect($.fn.placeholder).toHaveBeenCalled(); expect($.fn.placeholder).toHaveBeenCalled();
expect($.fn.placeholder.calls.mostRecent().object.selector).toBe("input, textarea"); expect($.fn.placeholder.calls.mostRecent().object.is($("input"))).toBe(true);
expect($.fn.placeholder.calls.mostRecent().object.is($("textarea"))).toBe(true);
}); });
it("initializes autosize for textareas", function(){ it("initializes autosize for textareas", function(){
spyOn(window, "autosize"); spyOn(window, "autosize");
app.setupForms(); app.setupForms();
expect(window.autosize).toHaveBeenCalled(); expect(window.autosize).toHaveBeenCalled();
expect(window.autosize.calls.mostRecent().args[0].selector).toBe("textarea"); expect(window.autosize.calls.mostRecent().args[0].is($("textarea"))).toBe(true);
}); });
}); });

View file

@ -10,7 +10,7 @@ describe("app.views.Search", function() {
spyOn(app.views.SearchBase.prototype, "initialize"); spyOn(app.views.SearchBase.prototype, "initialize");
this.view = new app.views.Search({el: "#search_people_form"}); this.view = new app.views.Search({el: "#search_people_form"});
var call = app.views.SearchBase.prototype.initialize.calls.mostRecent(); var call = app.views.SearchBase.prototype.initialize.calls.mostRecent();
expect(call.args[0].typeaheadInput.selector).toBe("#search_people_form #q"); expect(call.args[0].typeaheadInput.is($("#search_people_form #q"))).toBe(true);
expect(call.args[0].remoteRoute).toEqual({url: "/search"}); expect(call.args[0].remoteRoute).toEqual({url: "/search"});
}); });

View file

@ -119,42 +119,49 @@ describe("app.views.Base", function(){
context("calling out to third party plugins", function() { context("calling out to third party plugins", function() {
it("replaces .time with relative time ago in words", function() { it("replaces .time with relative time ago in words", function() {
this.view.templateName = false;
spyOn($.fn, "timeago"); spyOn($.fn, "timeago");
this.view.$el.append("<time/>");
this.view.render(); this.view.render();
expect($.fn.timeago).toHaveBeenCalled(); expect($.fn.timeago).toHaveBeenCalled();
expect($.fn.timeago.calls.mostRecent().object.selector).toBe("time"); expect($.fn.timeago.calls.mostRecent().object.first().is("time")).toBe(true);
}); });
it("initializes tooltips declared with the view's tooltipSelector property", function(){ it("initializes tooltips declared with the view's tooltipSelector property", function(){
this.view.templateName = false;
this.view.tooltipSelector = ".christopher_columbus, .barrack_obama, .block_user"; this.view.tooltipSelector = ".christopher_columbus, .barrack_obama, .block_user";
this.view.$el.append("<div class='christopher_columbus barrack_obama block_user'/>");
spyOn($.fn, "tooltip"); spyOn($.fn, "tooltip");
this.view.render(); this.view.render();
expect($.fn.tooltip.calls.mostRecent().object.selector).toBe(".christopher_columbus, .barrack_obama, .block_user"); expect(
}); $.fn.tooltip.calls.mostRecent().object.is(".christopher_columbus, .barrack_obama, .block_user")
).toBe(true);
it("applies infield labels", function(){
spyOn($.fn, "placeholder");
this.view.render();
expect($.fn.placeholder).toHaveBeenCalled();
expect($.fn.placeholder.calls.mostRecent().object.selector).toBe("input, textarea");
}); });
}); });
}); });
describe("#renderTemplate", function(){ describe("#renderTemplate", function(){
beforeEach(function() {
this.view.$el.htmlOriginal = this.view.$el.html;
spyOn(this.view.$el, "html").and.callFake(function() {
this.htmlOriginal("<input><textarea/></input>");
return this;
});
});
it("calls jQuery.placeholder() for inputs", function() { it("calls jQuery.placeholder() for inputs", function() {
spyOn($.fn, "placeholder"); spyOn($.fn, "placeholder");
this.view.renderTemplate(); this.view.renderTemplate();
expect($.fn.placeholder).toHaveBeenCalled(); expect($.fn.placeholder).toHaveBeenCalled();
expect($.fn.placeholder.calls.mostRecent().object.selector).toBe("input, textarea"); expect($.fn.placeholder.calls.mostRecent().object.is("input, textarea")).toBe(true);
}); });
it("initializes autosize for textareas", function(){ it("initializes autosize for textareas", function(){
spyOn(window, "autosize"); spyOn(window, "autosize");
this.view.renderTemplate(); this.view.renderTemplate();
expect(window.autosize).toHaveBeenCalled(); expect(window.autosize).toHaveBeenCalled();
expect(window.autosize.calls.mostRecent().args[0].selector).toBe("textarea"); expect(window.autosize.calls.mostRecent().args[0].is("textarea")).toBe(true);
}); });
}); });
}); });

View file

@ -8,7 +8,7 @@ describe("Diaspora.Mobile", function(){
it("calls autosize for textareas", function(){ it("calls autosize for textareas", function(){
Diaspora.Mobile.initialize(); Diaspora.Mobile.initialize();
expect(window.autosize).toHaveBeenCalled(); expect(window.autosize).toHaveBeenCalled();
expect(window.autosize.calls.mostRecent().args[0].selector).toBe("textarea"); expect(window.autosize.calls.mostRecent().args[0].is($("textarea"))).toBe(true);
}); });
it("deactivates shield", function(){ it("deactivates shield", function(){