Skip to content

Commit

Permalink
Fix unittest for search view
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed May 27, 2014
1 parent a670beb commit 1b86249
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
5 changes: 3 additions & 2 deletions test/test_view/drugs/centeredsearchform.rb
Expand Up @@ -11,6 +11,7 @@
require 'view/drugs/centeredsearchform'
require 'model/package'
require 'view/resulttemplate'
require 'custom/lookandfeelwrapper.rb'
require 'htmlgrid/labeltext'
require 'view/migel/product'
require 'remote/migel/model_super'
Expand Down Expand Up @@ -122,7 +123,7 @@ def test_init__data_counts
:limitation_text_count => 'limitation_text_count',
:recent_registration_count => 'recent_registration_count'
)
expected = {[0, 9]=>"legal-note center", [0, 7]=>"legal-note", [0, 13]=>"legal-note"}
expected = {[0, 9]=>"legal-note center", [0, 7]=>"legal-note", [0, 15]=>"legal-note"}
assert_equal(expected, @composite.init)
end
def test_init__facebook_fan
Expand Down Expand Up @@ -154,7 +155,7 @@ def test_init__facebook_fan
:limitation_text_count => 'limitation_text_count',
:recent_registration_count => 'recent_registration_count'
)
expected = {[0, 9]=>"legal-note center", [0, 7]=>"legal-note", [0, 13]=>"legal-note"}
expected = {[0, 9]=>"legal-note center", [0, 7]=>"legal-note", [0, 16]=>"legal-note"}
assert_equal(expected, @composite.init)
end
def test_create_link
Expand Down
2 changes: 1 addition & 1 deletion test/test_view/drugs/compare_search.rb
Expand Up @@ -62,7 +62,7 @@ def test_init
function selectSubmit() {
var popup = dojo.byId('searchbar_popup');
var searchbar = dojo.byId('searchbar');
if (!popup.style.overflowX.match(/auto/) && searchbar.value != '') {
if (popup && popup.style.overflowX.match(/auto/) && searchbar.value != '') {
setTimeout('show_progressbar(\\'widget_searchbar\\')', 10);
searchbar.form.submit();
}
Expand Down
14 changes: 10 additions & 4 deletions test/test_view/searchbar.rb
Expand Up @@ -33,14 +33,17 @@ def setup
@inputtext = ODDB::View::SearchBar.new('name', @model, @session, @container)
end
def test_init
expected = <<-SCRIPT
expected = %(
function get_to(url) {
var url2 = url.replace(/(\\d{13})[/,]+(\\d{13})/, '$1,$2').replace('/,','/').replace(/\\?$/,'').replace('\\?,', ',');
if (window.location.href == url2) { return; }
var form = document.createElement("form");
form.setAttribute("method", "GET");
form.setAttribute("action", url);
form.setAttribute("action", url2);
document.body.appendChild(form);
form.submit();
}
if (name.value!='lookup') {
var href = '_event_url' + encodeURIComponent(name.value.replace(/\\//, '%2F'));
Expand All @@ -50,7 +53,7 @@ def test_init
get_to(href);
};
return false;
SCRIPT
)
assert_equal(expected, @inputtext.init)
end
end
Expand Down Expand Up @@ -103,17 +106,20 @@ def test_to_html
class TestPrescriptionSearchBar <Minitest::Test
include FlexMock::TestCase
def setup
@persistent_user_input = flexmock('persistent_user_input', :keys => [])
@container = flexmock('container', :additional_javascripts => [])
@lnf = flexmock('lookandfeel',
:lookup => 'lookup',
:base_url => 'base_url',
:attributes => {},
:event_url => 'event_url',
:_event_url => '_event_url',
)
@session = flexmock('session',
:flavor => 'gcc',
:lookandfeel => @lnf,
:persistent_user_input => 'persistent_user_input',
:request_path => 'request_path',
:persistent_user_input => {'key' => 'value'},
:event => ''
)
@model = flexmock('model')
Expand Down

0 comments on commit 1b86249

Please sign in to comment.