Skip to content

Commit ac90533

Browse files
Merge pull request #84 from ekonstantinidis/rebranding
Rebranding
2 parents 3f6c3a8 + d53cb37 commit ac90533

File tree

16 files changed

+324
-265
lines changed

16 files changed

+324
-265
lines changed

images/logo-hor-white.png

-11.5 KB
Loading

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"src/js/components/notification.js": true,
2424
"src/js/components/notifications.js": true,
2525
"src/js/components/repository.js": true,
26+
"src/js/components/search.js": true,
2627
"src/js/components/settings.js": true,
27-
"src/js/components/footer.js": true,
2828
"src/js/components/search-input.js": true,
2929
"src/js/stores/auth.js": true,
3030
"src/js/stores/notifications.js": true,
@@ -100,7 +100,7 @@
100100
"grunt-contrib-copy": "=0.8.0",
101101
"grunt-contrib-less": "=1.0.1",
102102
"grunt-contrib-watch": "=0.6.1",
103-
"jest-cli": "=0.4.17",
103+
"jest-cli": "=0.4.18",
104104
"less": "=2.5.1"
105105
}
106106
}

src/js/__tests__/components/footer.js

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/js/__tests__/components/login.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ describe('Test for Login Component', function () {
2424
webContents: {
2525
on: function (event, callback) {
2626

27-
if (event == 'did-get-redirect-request') {
27+
if (event == 'will-navigate') {
2828
callback(
29-
'did-get-redirect-request',
30-
'http://www.github.com/?code=123123123',
29+
'will-navigate',
3130
'http://www.github.com/?code=123123123'
3231
);
3332
}
@@ -135,10 +134,9 @@ describe('Test for Login Component - Callback with Error', function () {
135134
webContents: {
136135
on: function (event, callback) {
137136

138-
if (event == 'did-get-redirect-request') {
137+
if (event == 'will-navigate') {
139138
callback(
140-
'did-get-redirect-request',
141-
'http://www.github.com/?error=FAILURE',
139+
'will-navigate',
142140
'http://www.github.com/?error=FAILURE'
143141
);
144142
}

src/js/__tests__/components/navigation.js

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,37 @@ describe('Test for Navigation', function () {
1414
var apiRequests, Actions, Navigation, AuthStore, Router;
1515

1616
beforeEach(function () {
17+
// Mock localStorage
18+
window.localStorage = {
19+
item: false,
20+
setItem: function (item) {
21+
this.item = item;
22+
},
23+
getItem: function () {
24+
return this.item;
25+
},
26+
clear: function () {
27+
this.item = false;
28+
}
29+
};
30+
1731
// Mock Electron's window.require
1832
// and remote.require('shell')
1933
window.require = function () {
2034
return {
35+
require: function () {
36+
return {
37+
openExternal: function () {
38+
return {};
39+
}
40+
};
41+
},
2142
sendChannel: function () {
2243
return;
2344
}
2445
};
2546
};
2647

27-
// Mock localStorage
28-
window.localStorage = {
29-
item: false,
30-
getItem: function () {
31-
return this.item;
32-
}
33-
};
34-
3548
apiRequests = require('../../utils/api-requests.js');
3649
Actions = require('../../actions/actions.js');
3750
AuthStore = require('../../stores/auth.js');
@@ -140,14 +153,43 @@ describe('Test for Navigation', function () {
140153

141154
var instance;
142155
React.withContext({router: new Router()}, function () {
143-
instance = TestUtils.renderIntoDocument(<Navigation />);
156+
instance = TestUtils.renderIntoDocument(<Navigation toggleSearch={function () {
157+
// Should toggle the search bar
158+
}} />);
144159
});
145160

146161
expect(instance.componentDidMount).toBeDefined();
162+
expect(instance.openBrowser).toBeDefined();
147163

148164
instance.goBack();
149165
instance.goToSettings();
150-
166+
instance.openBrowser();
167+
instance.showSearch();
151168
});
152169

170+
it('Should show the search icon & count label only if notifications', function () {
171+
172+
spyOn(Actions, 'getNotifications');
173+
174+
AuthStore.authStatus = function () {
175+
return true;
176+
};
177+
178+
var instance = TestUtils.renderIntoDocument(<Navigation />);
179+
180+
instance.state.notifications = [{
181+
title: 'test'
182+
}, {
183+
title: 'another test'
184+
}];
185+
186+
instance.forceUpdate();
187+
188+
var searchIcon = TestUtils.findRenderedDOMComponentWithClass(instance, 'fa-search');
189+
expect(searchIcon).toBeDefined();
190+
191+
var countLabel = TestUtils.findRenderedDOMComponentWithClass(instance, 'label-success');
192+
expect(countLabel).toBeDefined();
193+
194+
});
153195
});

src/js/__tests__/components/notification.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ describe('Test for Notification Component', function () {
2525
return {};
2626
}
2727
};
28+
},
29+
sendChannel: function () {
30+
return;
2831
}
2932
};
3033
};

src/js/__tests__/components/notifications.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ describe('Test for Notifications Component', function () {
9595
instance.state.searchTerm = 'gitify';
9696
matches = instance.matchesSearchTerm(response[0]);
9797
expect(matches).toBeTruthy();
98+
99+
instance.state.notifications = ['One', 'Two'];
100+
instance.openBrowser();
98101
});
99102

100103
it('Should only render repos that match the search term', function () {
Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1-
/* global jest, describe, beforeEach, it, expect, spyOn */
1+
/* global spyOn, jest, describe, beforeEach, it, expect */
22

33
jest.dontMock('reflux');
44
jest.dontMock('../../actions/actions.js');
5-
jest.dontMock('../../components/search-input.js');
5+
jest.dontMock('../../components/search.js');
66
jest.dontMock('../../stores/auth.js');
77

88
var React = require('react/addons');
99
var TestUtils = React.addons.TestUtils;
1010

11-
describe('Test for Search Input Component', function () {
11+
describe('Test for Footer', function () {
1212

13-
var Actions, AuthStore, SearchInput;
13+
var Actions, AuthStore, Search;
14+
15+
window.localStorage = {
16+
item: false,
17+
setItem: function (item) {
18+
this.item = item;
19+
},
20+
getItem: function () {
21+
return this.item;
22+
},
23+
clear: function () {
24+
this.item = false;
25+
}
26+
};
1427

1528
beforeEach(function () {
1629
// Mock Electron's window.require
@@ -27,52 +40,37 @@ describe('Test for Search Input Component', function () {
2740
};
2841
};
2942

30-
// Mock localStorage
31-
window.localStorage = {
32-
item: false,
33-
getItem: function () {
34-
return this.item;
35-
}
36-
};
37-
3843
Actions = require('../../actions/actions.js');
3944
AuthStore = require('../../stores/auth.js');
40-
SearchInput = require('../../components/search-input.js');
45+
Search = require('../../components/search.js');
4146
});
4247

4348
it('Should make a search', function () {
4449

4550
spyOn(Actions, 'updateSearchTerm');
4651
spyOn(Actions, 'clearSearchTerm');
4752

48-
var instance = TestUtils.renderIntoDocument(<SearchInput />);
53+
var instance = TestUtils.renderIntoDocument(<Search showSearch={true} />);
4954

5055
var wrapper = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'search-wrapper');
5156
expect(wrapper.length).toBe(1);
5257

5358
instance.clearSearch();
5459

55-
instance.onChange({
60+
instance.updateSearchTerm({
5661
target: {
5762
value: 'hello'
5863
}
5964
});
6065

6166
expect(Actions.updateSearchTerm).toHaveBeenCalledWith('hello');
62-
});
6367

64-
it('Should clear the search', function () {
65-
spyOn(Actions, 'clearSearchTerm');
66-
67-
var instance = TestUtils.renderIntoDocument(<SearchInput />);
68-
expect(Actions.clearSearchTerm).not.toHaveBeenCalled();
69-
70-
instance.clearSearch();
71-
expect(Actions.clearSearchTerm).toHaveBeenCalled();
68+
instance.componentWillReceiveProps({showSearch: false});
69+
expect(Actions.updateSearchTerm).toHaveBeenCalledWith('');
7270
});
7371

7472
it('Should only render clear button if search term is not empty', function () {
75-
var instance = TestUtils.renderIntoDocument(<SearchInput />);
73+
var instance = TestUtils.renderIntoDocument(<Search showSearch={true} />);
7674

7775
var clearButton = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'octicon-x');
7876
expect(clearButton.length).toBe(0);
@@ -84,4 +82,9 @@ describe('Test for Search Input Component', function () {
8482
expect(clearButton.length).toBe(1);
8583
});
8684

85+
it('Should hide the search bar', function () {
86+
var instance = TestUtils.renderIntoDocument(<Search showSearch={false} />);
87+
var searchBar = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'search-bar');
88+
expect(searchBar.length).toBe(0);
89+
});
8790
});

src/js/app.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var Router = require('react-router');
33

44
var AuthStore = require('./stores/auth');
55
var Navigation = require('./components/navigation');
6-
var Footer = require('./components/footer');
6+
var SearchBar = require('./components/search');
77
var LoginPage = require('./components/login');
88
var NotificationsPage = require('./components/notifications');
99
var SettingsPage = require('./components/settings');
@@ -23,12 +23,24 @@ var App = React.createClass({
2323
}
2424
},
2525

26+
getInitialState: function () {
27+
return {
28+
showSearch: false
29+
};
30+
},
31+
32+
toggleSearch: function () {
33+
this.setState({
34+
showSearch: !this.state.showSearch
35+
});
36+
},
37+
2638
render: function () {
2739
return (
2840
<div>
29-
<Navigation />
41+
<Navigation toggleSearch={this.toggleSearch} />
42+
<SearchBar showSearch={this.state.showSearch} />
3043
<RouteHandler />
31-
<Footer />
3244
</div>
3345
);
3446
}

src/js/components/footer.js

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)