Skip to content
Browse files

Initial test for cancel filters and slimed it to make it pass.

Also changed a variable name to follow naming convention
  • Loading branch information...
1 parent b4a64c7 commit 1d4de5cd841475008c66bed42f8f20c5e4946b42 @padi padi committed with padi Mar 11, 2012
Showing with 12 additions and 7 deletions.
  1. +4 −1 app/assets/javascripts/story_filter.js
  2. +8 −6 spec/javascripts/story_filter.spec.js
View
5 app/assets/javascripts/story_filter.js
@@ -4,7 +4,8 @@
ENTER: 13
};
- var input = this.find('input#filter_bar');
+ var input = this.find('input#filter_bar');
+ var cancel = this.find('#cancel');
input.keydown(function(event) {
if(event.keyCode == KEYCODES.ENTER) {
@@ -21,5 +22,7 @@
});
}
});
+
+ cancel.hide();
};
})(jQuery);
View
14 spec/javascripts/story_filter.spec.js
@@ -5,22 +5,22 @@ describe("filtering stories", function() {
});
describe("$.filterStories", function() {
- var main_container, input, filter;
+ var main_container, filter_container, input, cancel, stories_table;
var story1, story2;
beforeEach(function() {
filter_container = $('<div id="filter"></div>');
input = $('<input id="filter_bar" placeholder="Filter stories..." />');
- cancel = $('<span id="cancel"></span>');
+ cancel = $('<span id="cancel">x</span>');
filter_container.append(input).append(cancel);
- storiesTable = $('<table class="stories"></table>');
+ stories_table = $('<table class="stories"></table>');
story1 = $('<div id="1" class="story"><div class="story-title">Story with first keyword</div></div>');
story2 = $('<div id="2" class="story"><div class="story-title">Story with second keyword</div></div>');
- storiesTable.append(story1).append(story2);
+ stories_table.append(story1).append(story2);
main_container = $('<div></div>');
- main_container.append(filter_container).append(storiesTable);
+ main_container.append(filter_container).append(stories_table);
setFixtures(main_container);
filter_container.filterStories();
@@ -65,7 +65,9 @@ describe("filtering stories", function() {
});
describe("cancel", function() {
- xit("should not appear when filter bar is empty", function() {
+ it("should not appear when filter bar is empty", function() {
+ input.val("");
+ expect(cancel).not.toBeVisible();
});
xit("should appear when there are keywords inside the filter bar", function() {

0 comments on commit 1d4de5c

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