From f64eb9ff419a99f29197ff3646b1bbc46b6dedda Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Thu, 4 Jun 2015 12:08:54 +0200 Subject: [PATCH] Fix hound remarks --- .../javascripts/app/views/location_view.js | 10 +++- .../app/views/aspects_dropdown_view_spec.js | 58 +++++++++++-------- .../app/views/publisher_view_spec.js | 24 ++++---- 3 files changed, 52 insertions(+), 40 deletions(-) diff --git a/app/assets/javascripts/app/views/location_view.js b/app/assets/javascripts/app/views/location_view.js index 362f66fbb..f6aedec15 100644 --- a/app/assets/javascripts/app/views/location_view.js +++ b/app/assets/javascripts/app/views/location_view.js @@ -10,7 +10,7 @@ app.views.Location = Backbone.View.extend({ }, render: function(){ - $("", { alt: 'ajax-loader', src: ImagePaths.get('ajax-loader2.gif') }).appendTo(this.el); + $("", { alt: "ajax-loader", src: ImagePaths.get("ajax-loader2.gif") }).appendTo(this.el); }, getLocation: function(){ @@ -19,8 +19,12 @@ app.views.Location = Backbone.View.extend({ var locator = new OSM.Locator(); locator.getAddress(function(address, latlng){ $(element).empty(); - $("", { id: "location_address", value: address, - 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); }); diff --git a/spec/javascripts/app/views/aspects_dropdown_view_spec.js b/spec/javascripts/app/views/aspects_dropdown_view_spec.js index fc553fddb..9e637b390 100644 --- a/spec/javascripts/app/views/aspects_dropdown_view_spec.js +++ b/spec/javascripts/app/views/aspects_dropdown_view_spec.js @@ -63,49 +63,57 @@ describe("app.views.AspectsDropdown", function(){ }); }); - context('_selectAspects', function(){ + context("_selectAspects", function(){ beforeEach(function() { - this.view.$('li.selected').removeClass('selected'); - this.view.$('li.aspect_selector:eq(0)').addClass('selected'); + this.view.$("li.selected").removeClass("selected"); + this.view.$("li.aspect_selector:eq(0)").addClass("selected"); }); - 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']; + 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.view._selectAspects(this.ids); - expect(this.view.$('li.all_aspects').hasClass('selected')).toBeFalsy(); - 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(1)').hasClass('selected')).toBeTruthy(); + expect(this.view.$("li.all_aspects").hasClass("selected")).toBeFalsy(); + 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(1)").hasClass("selected")).toBeTruthy(); }); }); - context('_updateButton', function() { + context("_updateButton", function() { beforeEach(function() { - this.view.$('li.selected').removeClass('selected'); + this.view.$("li.selected").removeClass("selected"); }); - it('shows "Select aspects" when nothing is selected', function() { - this.view._updateButton('inAspectClass'); - expect(this.view.$('.btn.dropdown-toggle > .text').text()).toContain(Diaspora.I18n.t('aspect_dropdown.select_aspects')); + it("shows 'Select aspects' when nothing is selected", function() { + this.view._updateButton("inAspectClass"); + 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._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() { - this.view.$('li.aspect_selector:eq(1)').addClass('selected'); - this.view._updateButton('inAspectClass'); - expect(this.view.$('.btn.dropdown-toggle > .text').text()).toContain(this.view.$('li.aspect_selector:eq(1) .text').text()); + it("shows the name of the selected aspect ( == 1 )", function() { + this.view.$("li.aspect_selector:eq(1)").addClass("selected"); + this.view._updateButton("inAspectClass"); + 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() { - this.view.$('li.aspect_selector:eq(0)').addClass('selected'); - this.view.$('li.aspect_selector:eq(1)').addClass('selected'); - this.view._updateButton('inAspectClass'); - expect(this.view.$('.btn.dropdown-toggle > .text').text()).toContain(Diaspora.I18n.t('aspect_dropdown.toggle', { 'count':2 })); + it("shows the number of selected aspects ( > 1)", function() { + this.view.$("li.aspect_selector:eq(0)").addClass("selected"); + this.view.$("li.aspect_selector:eq(1)").addClass("selected"); + this.view._updateButton("inAspectClass"); + expect(this.view.$(".btn.dropdown-toggle > .text").text()).toContain( + Diaspora.I18n.t("aspect_dropdown.toggle", { count: 2 }) + ); }); }); }); diff --git a/spec/javascripts/app/views/publisher_view_spec.js b/spec/javascripts/app/views/publisher_view_spec.js index 17d9434ca..62fe357fe 100644 --- a/spec/javascripts/app/views/publisher_view_spec.js +++ b/spec/javascripts/app/views/publisher_view_spec.js @@ -306,8 +306,8 @@ describe("app.views.Publisher", function() { Diaspora.I18n.load({ stream: { public: 'Public' }}); this.viewAspectSelector = new app.views.PublisherAspectSelector({ - el: $('.public_toggle .aspect_dropdown'), - form: $('.content_creation form') + el: $(".public_toggle .aspect_dropdown"), + form: $(".content_creation form") }); this.view = new app.views.Publisher(); @@ -315,26 +315,26 @@ describe("app.views.Publisher", function() { }); it("initializes with 'all_aspects'", function(){ - expect($('#publisher #visibility-icon')).not.toHaveClass('globe'); - expect($('#publisher #visibility-icon')).toHaveClass('lock'); + expect($("#publisher #visibility-icon")).not.toHaveClass("globe"); + expect($("#publisher #visibility-icon")).toHaveClass("lock"); }); describe("toggles the selected entry visually", function(){ it("click on the first aspect", function(){ - this.view.$('.aspect_dropdown li.aspect_selector:first').click(); - expect($('#publisher #visibility-icon')).not.toHaveClass('globe'); - expect($('#publisher #visibility-icon')).toHaveClass('lock'); + this.view.$(".aspect_dropdown li.aspect_selector:first").click(); + expect($("#publisher #visibility-icon")).not.toHaveClass("globe"); + expect($("#publisher #visibility-icon")).toHaveClass("lock"); }); it("click on public", function(){ - this.view.$('.aspect_dropdown li.public').click(); - expect($('#publisher #visibility-icon')).toHaveClass('globe'); - expect($('#publisher #visibility-icon')).not.toHaveClass('lock'); + this.view.$(".aspect_dropdown li.public").click(); + expect($("#publisher #visibility-icon")).toHaveClass("globe"); + expect($("#publisher #visibility-icon")).not.toHaveClass("lock"); }); it("click on 'all aspects'", function(){ - expect($('#publisher #visibility-icon')).not.toHaveClass('globe'); - expect($('#publisher #visibility-icon')).toHaveClass('lock'); + expect($("#publisher #visibility-icon")).not.toHaveClass("globe"); + expect($("#publisher #visibility-icon")).toHaveClass("lock"); }); });