fix search specs
This commit is contained in:
parent
5aa86a5def
commit
b27edcb2d1
4 changed files with 33 additions and 36 deletions
|
|
@ -5,7 +5,9 @@ app.views.Header = app.views.Base.extend({
|
||||||
className : "dark-header",
|
className : "dark-header",
|
||||||
|
|
||||||
events : {
|
events : {
|
||||||
"click ul.dropdown li:first-child" : "toggleDropdown"
|
"click ul.dropdown li:first-child" : "toggleDropdown",
|
||||||
|
"focus #q": "toggleSearchActive",
|
||||||
|
"blur #q": "toggleSearchActive"
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize : function(options) {
|
initialize : function(options) {
|
||||||
|
|
@ -31,5 +33,10 @@ app.views.Header = app.views.Base.extend({
|
||||||
if(this.menuElement().hasClass("active") && !$(evt.target).parents("#user_menu").length) {
|
if(this.menuElement().hasClass("active") && !$(evt.target).parents("#user_menu").length) {
|
||||||
this.menuElement().removeClass("active");
|
this.menuElement().removeClass("active");
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleSearchActive: function(ev) {
|
||||||
|
$(ev.target).toggleClass('active', ev.type=='focusin');
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -71,4 +71,28 @@ describe("app.views.Header", function() {
|
||||||
expect(this.view.$(".dropdown")).not.toHaveClass("active");
|
expect(this.view.$(".dropdown")).not.toHaveClass("active");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe("search", function() {
|
||||||
|
var input;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
$('#jasmine_content').html(this.view.el);
|
||||||
|
input = $(this.view.el).find('#q');
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("focus", function() {
|
||||||
|
it("adds the class 'active' when the user focuses the text field", function() {
|
||||||
|
input.trigger('focus');
|
||||||
|
expect(input).toHaveClass("active");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("blur", function() {
|
||||||
|
it("removes the class 'active' when the user blurs the text field", function() {
|
||||||
|
input.focus().blur();
|
||||||
|
expect(input).not.toHaveClass("active");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,38 +7,4 @@ describe("View", function() {
|
||||||
it("is the object that helps the UI", function() {
|
it("is the object that helps the UI", function() {
|
||||||
expect(typeof View === "object").toBeTruthy();
|
expect(typeof View === "object").toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("publisher", function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
$("#jasmine_content").html(
|
|
||||||
'<div id="publisher">' +
|
|
||||||
'<form action="/status_messages" class="new_status_message" id="new_status_message" method="post">' +
|
|
||||||
'<textarea id="status_message_text" name="status_message[text]"></textarea>' +
|
|
||||||
'</form>' +
|
|
||||||
'</div>'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("search", function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
$("#jasmine_content").html(
|
|
||||||
'<input id="q" name="q" placeholder="Search" results="5" type="search" class="">'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
describe("focus", function() {
|
|
||||||
it("adds the class 'active' when the user focuses the text field", function() {
|
|
||||||
View.initialize();
|
|
||||||
$(View.search.selector).focus();
|
|
||||||
expect($(View.search.selector)).toHaveClass("active");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe("blur", function() {
|
|
||||||
it("removes the class 'active' when the user blurs the text field", function() {
|
|
||||||
View.initialize();
|
|
||||||
$(View.search.selector).focus().blur();
|
|
||||||
expect($(View.search.selector)).not.toHaveClass("active");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ describe("Diaspora", function() {
|
||||||
extended = $.extend(locale, data);
|
extended = $.extend(locale, data);
|
||||||
|
|
||||||
Diaspora.I18n.loadLocale(locale);
|
Diaspora.I18n.loadLocale(locale);
|
||||||
Diaspora.I18n.loadLocale(data;
|
Diaspora.I18n.loadLocale(data);
|
||||||
|
|
||||||
expect(Diaspora.I18n.locale).toEqual(extended);
|
expect(Diaspora.I18n.locale).toEqual(extended);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue