Fix hound remarks

This commit is contained in:
Steffen van Bergerem 2015-06-04 12:08:54 +02:00 committed by Jonne Haß
parent 98f11b944a
commit f64eb9ff41
3 changed files with 52 additions and 40 deletions

View file

@ -10,7 +10,7 @@ app.views.Location = Backbone.View.extend({
}, },
render: function(){ render: function(){
$("<img/>", { alt: 'ajax-loader', src: ImagePaths.get('ajax-loader2.gif') }).appendTo(this.el); $("<img/>", { alt: "ajax-loader", src: ImagePaths.get("ajax-loader2.gif") }).appendTo(this.el);
}, },
getLocation: function(){ getLocation: function(){
@ -19,8 +19,12 @@ app.views.Location = Backbone.View.extend({
var locator = new OSM.Locator(); var locator = new OSM.Locator();
locator.getAddress(function(address, latlng){ locator.getAddress(function(address, latlng){
$(element).empty(); $(element).empty();
$("<input/>", { id: "location_address", value: address, $("<input/>",
type: "text", class: "input-block-level form-control"}).appendTo($(element)); { id: "location_address",
value: address,
type: "text",
class: "input-block-level form-control"
}).appendTo($(element));
$("#location_coords").val(latlng.latitude + "," + latlng.longitude); $("#location_coords").val(latlng.latitude + "," + latlng.longitude);
}); });

View file

@ -63,49 +63,57 @@ describe("app.views.AspectsDropdown", function(){
}); });
}); });
context('_selectAspects', function(){ context("_selectAspects", function(){
beforeEach(function() { beforeEach(function() {
this.view.$('li.selected').removeClass('selected'); this.view.$("li.selected").removeClass("selected");
this.view.$('li.aspect_selector:eq(0)').addClass('selected'); this.view.$("li.aspect_selector:eq(0)").addClass("selected");
}); });
it('select aspects in the dropdown by a given list of ids', function() { it("select aspects in the dropdown by a given list of ids", function() {
this.ids = [this.view.$('li.aspect_selector:eq(1)').data('aspect_id'),'public']; this.ids = [this.view.$("li.aspect_selector:eq(1)").data("aspect_id"),"public"];
this.view._selectAspects(this.ids); this.view._selectAspects(this.ids);
expect(this.view.$('li.all_aspects').hasClass('selected')).toBeFalsy(); expect(this.view.$("li.all_aspects").hasClass("selected")).toBeFalsy();
expect(this.view.$('li.public').hasClass('selected')).toBeTruthy(); expect(this.view.$("li.public").hasClass("selected")).toBeTruthy();
expect(this.view.$('li.aspect_selector:eq(0)').hasClass('selected')).toBeFalsy(); expect(this.view.$("li.aspect_selector:eq(0)").hasClass("selected")).toBeFalsy();
expect(this.view.$('li.aspect_selector:eq(1)').hasClass('selected')).toBeTruthy(); expect(this.view.$("li.aspect_selector:eq(1)").hasClass("selected")).toBeTruthy();
}); });
}); });
context('_updateButton', function() { context("_updateButton", function() {
beforeEach(function() { beforeEach(function() {
this.view.$('li.selected').removeClass('selected'); this.view.$("li.selected").removeClass("selected");
}); });
it('shows "Select aspects" when nothing is selected', function() { it("shows 'Select aspects' when nothing is selected", function() {
this.view._updateButton('inAspectClass'); this.view._updateButton("inAspectClass");
expect(this.view.$('.btn.dropdown-toggle > .text').text()).toContain(Diaspora.I18n.t('aspect_dropdown.select_aspects')); expect(this.view.$(".btn.dropdown-toggle > .text").text()).toContain(
Diaspora.I18n.t("aspect_dropdown.select_aspects")
);
}); });
it('shows the name of the selected radio button', function() { it("shows the name of the selected radio button", function() {
this.view.$("li.all_aspects").addClass("selected"); this.view.$("li.all_aspects").addClass("selected");
this.view._updateButton("inAspectClass"); this.view._updateButton("inAspectClass");
expect(this.view.$(".btn.dropdown-toggle > .text").text()).toContain(Diaspora.I18n.t("aspect_dropdown.all_aspects")); expect(this.view.$(".btn.dropdown-toggle > .text").text()).toContain(
Diaspora.I18n.t("aspect_dropdown.all_aspects")
);
}); });
it('shows the name of the selected aspect ( == 1 )', function() { it("shows the name of the selected aspect ( == 1 )", function() {
this.view.$('li.aspect_selector:eq(1)').addClass('selected'); this.view.$("li.aspect_selector:eq(1)").addClass("selected");
this.view._updateButton('inAspectClass'); this.view._updateButton("inAspectClass");
expect(this.view.$('.btn.dropdown-toggle > .text').text()).toContain(this.view.$('li.aspect_selector:eq(1) .text').text()); expect(this.view.$(".btn.dropdown-toggle > .text").text()).toContain(
this.view.$("li.aspect_selector:eq(1) .text").text()
);
}); });
it('shows the number of selected aspects ( > 1)', function() { it("shows the number of selected aspects ( > 1)", function() {
this.view.$('li.aspect_selector:eq(0)').addClass('selected'); this.view.$("li.aspect_selector:eq(0)").addClass("selected");
this.view.$('li.aspect_selector:eq(1)').addClass('selected'); this.view.$("li.aspect_selector:eq(1)").addClass("selected");
this.view._updateButton('inAspectClass'); this.view._updateButton("inAspectClass");
expect(this.view.$('.btn.dropdown-toggle > .text').text()).toContain(Diaspora.I18n.t('aspect_dropdown.toggle', { 'count':2 })); expect(this.view.$(".btn.dropdown-toggle > .text").text()).toContain(
Diaspora.I18n.t("aspect_dropdown.toggle", { count: 2 })
);
}); });
}); });
}); });

View file

@ -306,8 +306,8 @@ describe("app.views.Publisher", function() {
Diaspora.I18n.load({ stream: { public: 'Public' }}); Diaspora.I18n.load({ stream: { public: 'Public' }});
this.viewAspectSelector = new app.views.PublisherAspectSelector({ this.viewAspectSelector = new app.views.PublisherAspectSelector({
el: $('.public_toggle .aspect_dropdown'), el: $(".public_toggle .aspect_dropdown"),
form: $('.content_creation form') form: $(".content_creation form")
}); });
this.view = new app.views.Publisher(); this.view = new app.views.Publisher();
@ -315,26 +315,26 @@ describe("app.views.Publisher", function() {
}); });
it("initializes with 'all_aspects'", function(){ it("initializes with 'all_aspects'", function(){
expect($('#publisher #visibility-icon')).not.toHaveClass('globe'); expect($("#publisher #visibility-icon")).not.toHaveClass("globe");
expect($('#publisher #visibility-icon')).toHaveClass('lock'); expect($("#publisher #visibility-icon")).toHaveClass("lock");
}); });
describe("toggles the selected entry visually", function(){ describe("toggles the selected entry visually", function(){
it("click on the first aspect", function(){ it("click on the first aspect", function(){
this.view.$('.aspect_dropdown li.aspect_selector:first').click(); this.view.$(".aspect_dropdown li.aspect_selector:first").click();
expect($('#publisher #visibility-icon')).not.toHaveClass('globe'); expect($("#publisher #visibility-icon")).not.toHaveClass("globe");
expect($('#publisher #visibility-icon')).toHaveClass('lock'); expect($("#publisher #visibility-icon")).toHaveClass("lock");
}); });
it("click on public", function(){ it("click on public", function(){
this.view.$('.aspect_dropdown li.public').click(); this.view.$(".aspect_dropdown li.public").click();
expect($('#publisher #visibility-icon')).toHaveClass('globe'); expect($("#publisher #visibility-icon")).toHaveClass("globe");
expect($('#publisher #visibility-icon')).not.toHaveClass('lock'); expect($("#publisher #visibility-icon")).not.toHaveClass("lock");
}); });
it("click on 'all aspects'", function(){ it("click on 'all aspects'", function(){
expect($('#publisher #visibility-icon')).not.toHaveClass('globe'); expect($("#publisher #visibility-icon")).not.toHaveClass("globe");
expect($('#publisher #visibility-icon')).toHaveClass('lock'); expect($("#publisher #visibility-icon")).toHaveClass("lock");
}); });
}); });