@@ -82,6 +82,47 @@ describe('Test for Notifications Component', function () {
8282 errors = TestUtils . scryRenderedDOMComponentsWithClass ( instance , 'errored' ) ;
8383 expect ( errors . length ) . toBe ( 1 ) ;
8484
85+ expect ( instance . areIn ( 'ekonstantinidis/gitify' , 'gitify' ) ) . toBeTruthy ( ) ;
86+ expect ( instance . areIn ( 'ekonstantinidis/gitify' , 'hello' ) ) . toBeFalsy ( ) ;
87+
88+ instance . state . searchTerm = 'hello' ;
89+ var matches = instance . matchesSearchTerm ( response [ 0 ] ) ;
90+ expect ( matches ) . toBeFalsy ( ) ;
91+
92+ instance . state . searchTerm = 'gitify' ;
93+ matches = instance . matchesSearchTerm ( response [ 0 ] ) ;
94+ expect ( matches ) . toBeTruthy ( ) ;
95+ } ) ;
96+
97+ it ( 'Should only render repos that match the search term' , function ( ) {
98+ AuthStore . authStatus = function ( ) {
99+ return true ;
100+ } ;
101+
102+ var instance = TestUtils . renderIntoDocument ( < Notifications /> ) ;
103+
104+ var response = [ [ {
105+ 'repository' : {
106+ 'full_name' : 'ekonstantinidis/gitify' ,
107+ 'owner' : {
108+ 'avatar_url' : 'http://avatar.url'
109+ }
110+ } ,
111+ 'subject' : {
112+ 'type' : 'Issue'
113+ }
114+ } ] ] ;
115+
116+ NotificationsStore . trigger ( response ) ;
117+
118+ var notifications = TestUtils . scryRenderedDOMComponentsWithClass ( instance , 'repository' ) ;
119+ expect ( notifications . length ) . toBe ( 1 ) ;
120+
121+ instance . state . searchTerm = 'hello' ;
122+ instance . forceUpdate ( ) ;
123+
124+ notifications = TestUtils . scryRenderedDOMComponentsWithClass ( instance , 'repository' ) ;
125+ expect ( notifications . length ) . toBe ( 0 ) ;
85126 } ) ;
86127
87128} ) ;
0 commit comments