Skip to content
Browse files

Fix tests and make them run correctly

  • Loading branch information...
1 parent 25732d7 commit 1417cf47a2e8cdfea7318cbe728ba9c362235b56 @retro retro committed Oct 11, 2011
Showing with 34 additions and 34 deletions.
  1. +4 −4 index.html
  2. +3 −3 srchr/search/views/init.ejs
  3. +5 −5 srchr/srchr.html
  4. +22 −22 srchr/test/funcunit/srchr_test.js
View
8 index.html
@@ -18,13 +18,13 @@
<h3>Results</h3>
<ul id='resultsTab'>
- <li><a href='#flickr'>Flickr</a></li>
+ <li><a href='#twitter'>Twitter</a></li>
<li><a href='#upcoming'>Upcoming</a></li>
- <li><a href='#twitter'>Twitter</a></li>
+ <li><a href='#flickr'>Flickr</a></li>
</ul>
- <div id='flickr'></div>
- <div id='upcoming'></div>
<div id='twitter'></div>
+ <div id='upcoming'></div>
+ <div id='flickr'></div>
</div>
View
6 srchr/search/views/init.ejs
@@ -1,14 +1,14 @@
<form action=''>
<ul class='options'>
<li>
- <label for="cb_flickr"><input type='checkbox' id="cb_flickr" name='types' value='Srchr.Models.Flickr'/> Flickr</label>
-
+ <label for="cb_twitter"><input id="cb_twitter" type='checkbox' name='types' value='Srchr.Models.Twitter'/> Twitter</label>
</li>
<li>
<label for="cb_upcoming"><input id="cb_upcoming" type='checkbox' name='types' value='Srchr.Models.Upcoming'/> Upcoming</label>
</li>
<li>
- <label for="cb_twitter"><input id="cb_twitter" type='checkbox' name='types' value='Srchr.Models.Twitter'/> Twitter</label>
+ <label for="cb_flickr"><input type='checkbox' id="cb_flickr" name='types' value='Srchr.Models.Flickr'/> Flickr</label>
+
</li>
</ul>
View
10 srchr/srchr.html
@@ -18,14 +18,14 @@
<h3>Results</h3>
<ul id='resultsTab'>
- <li><a href='#flickr'>Flickr</a></li>
- <li><a href='#upcoming'>Upcoming</a></li>
<li><a href='#twitter'>Twitter</a></li>
+ <li><a href='#upcoming'>Upcoming</a></li>
+ <li><a href='#flickr'>Flickr</a></li>
+
</ul>
- <div id='flickr'></div>
- <div id='upcoming'></div>
<div id='twitter'></div>
-
+ <div id='upcoming'></div>
+ <div id='flickr'></div>
</div>
</div>
View
44 srchr/test/funcunit/srchr_test.js
@@ -3,29 +3,32 @@ module("srchr", {
S.open("//srchr/srchr.html");
},
checkYahooOnlyResults : function(){
- ok(S('#yahoo').html(), 'Results were retrieved.')
- ok(S('#resultsTab li:eq(0)').hasClass('disabled'), "Non-selected tab Flickr is disabled.")
- ok(!S('#resultsTab li:eq(1)').hasClass('disabled'), "Selected tab Yahoo is enabled.")
- ok(S('#resultsTab li:eq(2)').hasClass('disabled'), "Non-selected tab Upcoming is disabled.")
+ ok(S('#flickr').html(), 'Results were retrieved.')
+ ok(!S('#resultsTab li:eq(0)').hasClass('disabled'), "Selected tab Twitter is enabled.")
+ ok(S('#resultsTab li:eq(1)').hasClass('disabled'), "Non-selected tab Upcoming is disabled.")
+ ok(S('#resultsTab li:eq(2)').hasClass('disabled'), "Non-selected tab Flickr is disabled.")
}
});
test('Search shows results in selected service', function(){
- S('input[value=Srchr\\.Models\\.Yahoo]').click();
+ S('input[value=Srchr\\.Models\\.Twitter]').click();
S('#query').click().type('Dogs\r');
// wait until there are 2 results
- S("#yahoo li").exists( function(){
+ S("#twitter li").exists( function(){
- ok(true, "We see results in yahoo");
+ ok(true, "We see results in twitter");
// make sure we see dogs in the history
- equals(S("#history .search .text").text() , "Dogs y", "we see dogs correctly");
+
+ var r = /Dogs\st/;
+
+ ok(r.test(S("#history .search .text").text()), "we see dogs correctly");
// make sure flickr and everyone else is diabled
- ok(S('#resultsTab li:eq(0)').hasClass('disabled'), "Flickr is disabled.");
+ ok(S('#resultsTab li:eq(1)').hasClass('disabled'), "Flickr is disabled.");
ok(S('#resultsTab li:eq(2)').hasClass('disabled'), "Upcoming is disabled.");
});
@@ -34,32 +37,29 @@ test('Search shows results in selected service', function(){
})
test('Switching results tabs', function(){
- S('input[value=Srchr\\.Models\\.Yahoo]').click();
+ S('input[value=Srchr\\.Models\\.Twitter]').click();
S('input[value=Srchr\\.Models\\.Flickr]').click();
S('#query').click().type('Cats\r');
- S("#flickr li").exists( function(){
+ S("#twitter li").exists( function(){
- equals(S('#flickr').css('display'), 'block', 'Flickr results panel is visible')
-
- S('#resultsTab li:eq(1)').click(function(){
-
- equals(S('#flickr').css('display'), 'none', 'Flickr results panel is hidden')
-
- equals(S('#yahoo').css('display'), 'block', 'Yahoo results panel is visible')
- })
-
+ equals(S('#twitter').css('display'), 'block', 'Twitter results panel is visible')
})
+
+ S('#resultsTab li:eq(2) a').exists().click(function(){
+ equals(S('#twitter').css('display'), 'none', 'Twitter results panel is hidden')
+ equals(S('#flickr').css('display'), 'block', 'Flickr results panel is visible')
+ })
})
test('Clicking history entries re-creates the search', function(){
S('.srchr_models_search_Dogs').click(function(){
equals(S('#query').val(), "Dogs", 'Dogs was put back into the query field')
});
- S("#yahoo li").exists( function(){
- ok(true, "We see results in yahoo");
+ S("#twitter li").exists( function(){
+ ok(true, "We see results in twitter");
})
})

0 comments on commit 1417cf4

Please sign in to comment.
Something went wrong with that request. Please try again.