jasmine spec up and working. code out of (no longer called) contacts info page object. Fixed namespaces and created jasmine fixture for empty and pending searches.
This commit is contained in:
parent
ee237c6c5f
commit
9de477cf5a
5 changed files with 30 additions and 30 deletions
|
|
@ -22,7 +22,7 @@
|
|||
%p
|
||||
=t('.searching')
|
||||
:javascript
|
||||
$(document).ready(function() { setTimeout("runDelayedSearch('#{@background_query}')", 10000); });
|
||||
$(document).ready(function() { List.startSearchDelay('#{@background_query}') } );
|
||||
- else
|
||||
%p
|
||||
=t('.no_one_found')
|
||||
|
|
|
|||
|
|
@ -32,7 +32,26 @@ var List = {
|
|||
};
|
||||
}
|
||||
});
|
||||
},
|
||||
runDelayedSearch: function( searchTerm ) {
|
||||
$.ajax({
|
||||
dataType: 'json',
|
||||
url: '/people/refresh_search',
|
||||
data: { q: searchTerm },
|
||||
success: List.handleSearchRefresh
|
||||
});
|
||||
},
|
||||
handleSearchRefresh: function( data ) {
|
||||
if ( data.search_count > 0 ) {
|
||||
$("#people_stream.stream").html( data.search_html );
|
||||
} else {
|
||||
$("#people_stream.stream").html( "<p>" + Diaspora.I18n.t("people.not_found") + "</p>" );
|
||||
}
|
||||
},
|
||||
startSearchDelay: function ( theSearch ) {
|
||||
setTimeout( "List.runDelayedSearch('" + theSearch + "')", 10000);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
|
|
|
|||
|
|
@ -5,21 +5,5 @@ Diaspora.Pages.ContactsIndex = function() {
|
|||
self.infiniteScroll = self.instantiate("InfiniteScroll");
|
||||
$('.conversation_button').twipsy({position: 'below'});
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
function runDelayedSearch( searchTerm ) {
|
||||
$.ajax({
|
||||
dataType: 'json',
|
||||
url: '/people/refresh_search',
|
||||
data: { q: searchTerm },
|
||||
success: handleSearchRefresh
|
||||
});
|
||||
}
|
||||
|
||||
function handleSearchRefresh(data) {
|
||||
if ( data.search_count > 0 ) {
|
||||
$("#people_stream.stream").html( data.search_html );
|
||||
} else {
|
||||
$("#people_stream.stream").html( "<p>" + Diaspora.I18n.t("people.not_found") + "</p>" );
|
||||
}
|
||||
}
|
||||
|
|
@ -10,12 +10,12 @@ describe PeopleController do
|
|||
sign_in :user, bob
|
||||
end
|
||||
|
||||
it "generates a jasmine fixture", :fixture => true do
|
||||
it "generates a jasmine fixture with no query", :fixture => true do
|
||||
get :index
|
||||
save_fixture(html_for("body"), "empty_people_search")
|
||||
end
|
||||
it "generates a jasmine fixture", :fixture => true do
|
||||
get :index, :id => "sample@diaspor.us"
|
||||
it "generates a jasmine fixture trying an external search", :fixture => true do
|
||||
get :index, :q => "sample@diaspor.us"
|
||||
save_fixture(html_for("body"), "pending_external_people_search")
|
||||
end
|
||||
end
|
||||
|
|
@ -3,30 +3,27 @@
|
|||
* the COPYRIGHT file.
|
||||
*/
|
||||
|
||||
describe("Publisher", function() {
|
||||
describe("List", function() {
|
||||
|
||||
describe("runDelayedSearch", function() {
|
||||
beforeEach( function(){
|
||||
spec.loadFixture('pending_external_people_search');
|
||||
Publisher.open();
|
||||
});
|
||||
|
||||
it('gets called on initialize', function(){
|
||||
spyOn(Publisher, 'runDelayedSearch');
|
||||
Publisher.initialize();
|
||||
expect(Publisher.runDelayedSearch).toHaveBeenCalled();
|
||||
spyOn( List, 'startSearchDelay');
|
||||
spec.loadFixture('pending_external_people_search');
|
||||
expect(List.startSearchDelay).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("runDelayedSearch", function() {
|
||||
beforeEach( function(){
|
||||
spec.loadFixture('empty_people_search');
|
||||
Publisher.open();
|
||||
List.initialize();
|
||||
});
|
||||
|
||||
it('inserts contact html', function(){
|
||||
Publisher.initialize();
|
||||
Publisher.handleSearchRefresh( "<div class='testing_insert_div'>hello</div>");
|
||||
List.handleSearchRefresh( { count:1,search_html: '<div class='testing_insert_div'>hello</div>' } );
|
||||
expect($(".testing_insert_div").text().toEqual( "hello" ));
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue