Skip to content

Commit c960eb1

Browse files
author
Emmanouil Konstantinidis
committed
Initialize Tests
1 parent 8248646 commit c960eb1

File tree

8 files changed

+76
-19
lines changed

8 files changed

+76
-19
lines changed

package.json

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,45 @@
1010
"watch": "grunt build && npm build && npm run watch-js | grunt watch",
1111
"start": "electron .",
1212
"dist": "rm -rf Gitify.app/ && electron-packager . Gitify --platform=darwin --arch=x64 --version=0.27.1 --icon=images/app-icon.icns --prune --ignore=src",
13-
"test": "jsxhint --reporter node_modules/jshint-stylish/stylish.js 'src/**/*.js', 'index.js' --exclude 'Gruntfile.js'"
13+
"test": "jsxhint --reporter node_modules/jshint-stylish/stylish.js 'src/**/*.js', 'index.js' --exclude 'Gruntfile.js' && jscs 'src/js/' && jest"
14+
},
15+
"jscsConfig": {
16+
"esprima": "esprima-fb",
17+
"disallowMultipleVarDecl": "exceptUndefined",
18+
"validateQuoteMarks": {
19+
"mark": "'",
20+
"escape": false
21+
},
22+
"validateParameterSeparator": ", ",
23+
"validateIndentation": 2,
24+
"requireSpacesInFunction": {
25+
"beforeOpeningRoundBrace": true,
26+
"beforeOpeningCurlyBrace": true
27+
},
28+
"requireSpacesInConditionalExpression": {
29+
"afterTest": true,
30+
"beforeConsequent": true,
31+
"afterConsequent": true,
32+
"beforeAlternate": true
33+
},
34+
"disallowTrailingWhitespace": true,
35+
"maximumLineLength": 100,
36+
"requireCurlyBraces": true,
37+
"disallowMixedSpacesAndTabs": true,
38+
"requireSpaceBeforeBinaryOperators": true,
39+
"safeContextKeyword": [
40+
"self"
41+
],
42+
"disallowMultipleLineBreaks": true,
43+
"disallowMultipleLineStrings": true,
44+
"disallowSpaceAfterObjectKeys": true,
45+
"disallowNewlineBeforeBlockStatements": true,
46+
"disallowTrailingComma": true,
47+
"requireCommaBeforeLineBreak": true,
48+
"requireSpaceBetweenArguments": true,
49+
"requireSpaceBeforeBlockStatements": true,
50+
"requireSpaceBeforeObjectValues": true,
51+
"requireSpacesInForStatement": true
1452
},
1553
"repository": {
1654
"type": "git",
@@ -46,11 +84,14 @@
4684
"devDependencies": {
4785
"electron-packager": "=4.1.2",
4886
"electron-prebuilt": "=0.27.1",
87+
"esprima-fb": "^15001.1.0-dev-harmony-fb",
4988
"grunt": "=0.4.5",
5089
"grunt-contrib-clean": "=0.6.0",
5190
"grunt-contrib-copy": "=0.8.0",
5291
"grunt-contrib-less": "=1.0.1",
5392
"grunt-contrib-watch": "=0.6.1",
93+
"jest-cli": "=0.4.5",
94+
"jscs": "^1.13.1",
5495
"jshint-stylish": "=1.0.2",
5596
"jsxhint": "=0.15.0",
5697
"less": "=2.5.1"

src/js/__tests__/basic.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* global describe, it, expect */
2+
3+
describe('basic', function () {
4+
it('adds two and two and gets four', function () {
5+
expect(2 + 2).toBe(4);
6+
});
7+
});

src/js/actions/actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var Actions = Reflux.createActions({
44

55
'login': {},
66
'logout': {},
7-
'getNotifications': {asyncResult: true},
7+
'getNotifications': {asyncResult: true}
88

99
});
1010

src/js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var App = React.createClass({
1616
statics: {
1717
willTransitionTo: function (transition) {
1818
if (transition.path !== '/login' && !AuthStore.authStatus()) {
19-
console.log("Not logged in. Redirecting to login.");
19+
console.log('Not logged in. Redirecting to login.');
2020
transition.redirect('login', {});
2121
}
2222
}

src/js/components/footer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ var Footer = React.createClass({
1212
return (
1313
<div className='container-fluid footer'>
1414
<div className='row'>
15-
<div className='col-xs-12 right' onClick={this.openRepoBrowser}>Fork me on <span className="octicon octicon-mark-github"/></div>
15+
<div
16+
className='col-xs-12 right'
17+
onClick={this.openRepoBrowser}>
18+
Fork me on <span className="octicon octicon-mark-github"/>
19+
</div>
1620
</div>
1721
</div>
1822
);

src/js/components/login.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,27 @@ var Login = React.createClass({
1919

2020
// Start Login
2121
var options = {
22-
client_id: '27a352516d3341cee376',
23-
client_secret: '626a199b0656c55b2cbf3a3199e573ce17f549bc',
24-
scope: ["user:email", "notifications"]
22+
client_id: '27a352516d3341cee376',
23+
client_secret: '626a199b0656c55b2cbf3a3199e573ce17f549bc',
24+
scope: ['user:email', 'notifications']
2525
};
2626

2727
//Build the OAuth consent page URL
28-
var authWindow = new BrowserWindow({ width: 800, height: 600, show: true, 'node-integration': false });
28+
var authWindow = new BrowserWindow({
29+
width: 800,
30+
height: 600,
31+
show: true,
32+
'node-integration': false
33+
});
2934
var githubUrl = 'https://github.com/login/oauth/authorize?';
3035
var authUrl = githubUrl + 'client_id=' + options.client_id + '&scope=' + options.scope;
3136
authWindow.loadUrl(authUrl);
3237

33-
authWindow.webContents.on('did-get-redirect-request', function(event, oldUrl, newUrl) {
38+
authWindow.webContents.on('did-get-redirect-request', function (event, oldUrl, newUrl) {
3439

35-
var raw_code = /code=([^&]*)/.exec(newUrl) || null,
36-
code = (raw_code && raw_code.length > 1) ? raw_code[1] : null,
37-
error = /\?error=(.+)$/.exec(newUrl);
40+
var raw_code = /code=([^&]*)/.exec(newUrl) || null;
41+
var code = (raw_code && raw_code.length > 1) ? raw_code[1] : null;
42+
var error = /\?error=(.+)$/.exec(newUrl);
3843

3944
if (code || error) {
4045
// Close the browser if code found or error
@@ -45,14 +50,14 @@ var Login = React.createClass({
4550
if (code) {
4651
self.requestGithubToken(options, code);
4752
} else if (error) {
48-
alert("Oops! Something went wrong and we couldn't log you in using Github. Please try again.");
53+
alert('Oops! Something went wrong and we couldn\'t log you in using Github. Please try again.');
4954
}
5055

5156
});
5257

5358
// If "Done" button is pressed, hide "Loading"
5459
authWindow.on('close', function() {
55-
authWindow = null;
60+
authWindow = null;
5661
}, false);
5762

5863
},

src/js/components/navigation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var Navigation = React.createClass({
2727
var self = this;
2828
var iFrequency = 60000;
2929
var myInterval = 0;
30-
if (myInterval > 0) clearInterval(myInterval);
30+
if (myInterval > 0) { clearInterval(myInterval); }
3131
setInterval( function () {
3232
self.refreshNotifications();
3333
}, iFrequency );

src/js/stores/notifications.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ var NotificationsStore = Reflux.createStore({
4040
},
4141

4242
onGetNotificationsCompleted: function (notifications) {
43-
var groupedNotifications = _.groupBy(notifications, function(object){
43+
var groupedNotifications = _.groupBy(notifications, function (object){
4444
return object.repository.full_name;
4545
});
4646

47-
var array= [];
48-
_.map(groupedNotifications, function(obj, i) {
47+
var array = [];
48+
_.map(groupedNotifications, function (obj, i) {
4949
array.push(obj);
5050
});
5151

@@ -54,7 +54,7 @@ var NotificationsStore = Reflux.createStore({
5454
},
5555

5656
onGetNotificationsFailed: function (error) {
57-
console.log("Errored." + error);
57+
console.log('Errored.' + error);
5858
}
5959

6060
});

0 commit comments

Comments
 (0)