1- /* global jest, describe, beforeEach, it, expect, spyOn */
1+ /* global jest, describe, beforeEach, it, expect */
22
33jest . dontMock ( 'reflux' ) ;
44jest . dontMock ( '../../actions/actions.js' ) ;
@@ -11,7 +11,7 @@ var TestUtils = React.addons.TestUtils;
1111
1212describe ( 'Test for Navigation' , function ( ) {
1313
14- var apiRequests , Actions , Navigation , AuthStore ;
14+ var apiRequests , Actions , Navigation , AuthStore , Router ;
1515
1616 beforeEach ( function ( ) {
1717 // Mock Electron's window.require
@@ -36,6 +36,7 @@ describe('Test for Navigation', function () {
3636 Actions = require ( '../../actions/actions.js' ) ;
3737 AuthStore = require ( '../../stores/auth.js' ) ;
3838 Navigation = require ( '../../components/navigation.js' ) ;
39+ Router = require ( 'react-router' ) ;
3940 } ) ;
4041
4142 it ( 'Should load the navigation component for logged out users' , function ( ) {
@@ -56,20 +57,32 @@ describe('Test for Navigation', function () {
5657
5758 } ) ;
5859
59-
6060 it ( 'Should load the navigation component for logged in users' , function ( ) {
6161
6262 AuthStore . authStatus = function ( ) {
6363 return true ;
6464 } ;
6565
66- var instance = TestUtils . renderIntoDocument ( < Navigation /> ) ;
66+ var instance ;
67+ React . withContext ( { router : new Router ( ) } , function ( ) {
68+ instance = TestUtils . renderIntoDocument ( < Navigation /> ) ;
69+ } ) ;
70+
6771 expect ( instance . state . loading ) . toBeFalsy ( ) ;
6872 expect ( instance . refreshNotifications ) . toBeDefined ( ) ;
6973 expect ( instance . refreshDone ) . toBeDefined ( ) ;
7074 expect ( instance . logOut ) . toBeDefined ( ) ;
7175 expect ( instance . appQuit ) . toBeDefined ( ) ;
7276
77+ var logoutIcon = TestUtils . scryRenderedDOMComponentsWithClass ( instance , 'fa-sign-out' ) ;
78+ expect ( logoutIcon . length ) . toBe ( 1 ) ;
79+
80+ // Now Logout
81+ instance . logOut ( ) ;
82+ AuthStore . trigger ( ) ;
83+ logoutIcon = TestUtils . scryRenderedDOMComponentsWithClass ( instance , 'fa-sign-out' ) ;
84+ expect ( logoutIcon . length ) . toBe ( 0 ) ;
85+
7386 } ) ;
7487
7588} ) ;
0 commit comments