Skip to content

Commit 0039735

Browse files
committed
Test rendering of clear button
1 parent 20f7c78 commit 0039735

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/js/__tests__/components/search-input.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,17 @@ describe('Test for Search Input Component', function () {
7171
expect(Actions.clearSearchTerm).toHaveBeenCalled();
7272
});
7373

74+
it('Should only render clear button if search term is not empty', function () {
75+
var instance = TestUtils.renderIntoDocument(<SearchInput />);
76+
77+
var clearButton = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'octicon-x');
78+
expect(clearButton.length).toBe(0);
79+
80+
instance.state.searchTerm = 'hello';
81+
instance.forceUpdate();
82+
83+
clearButton = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'octicon-x');
84+
expect(clearButton.length).toBe(1);
85+
});
86+
7487
});

0 commit comments

Comments
 (0)