Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit d500698

Browse files
author
Nick Litwin
committed
Fix tests
2 parents 3e9b33f + 6da9a09 commit d500698

File tree

200 files changed

+5990
-21520
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+5990
-21520
lines changed

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/*
2+
assets/*
3+
report/*

.eslintrc.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"env": {
1010
"es6": true,
1111
"browser": true,
12-
"node": true
12+
"node": true,
13+
"mocha": true,
14+
"jquery": true
1315
},
1416
"extends": "eslint:recommended",
1517
"ecmaFeatures": {

.travis.yml

+38-39
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,42 @@
11
language: node_js
22
node_js:
3-
- 5.5.0
3+
- 5.5.0
44
install:
5-
- npm install
6-
before_script:
7-
- export DISPLAY=:99.0
8-
- sh -e /etc/init.d/xvfb start
9-
- sleep 3 # give xvfb some time to start
5+
- npm install
106
script:
11-
- npm test
12-
- webpack --bail --progress --build --tc
7+
- npm run lint && npm test && npm run build
138
sudo: false
149
deploy:
15-
- provider: s3
16-
cache_control: private, no-store, no-cache, must-revalidate, max-age=0
17-
detect_encoding: true
18-
access_key_id: $AWS_KEY
19-
secret_access_key: $AWS_SECRET
20-
bucket: app.topcoder-dev.com
21-
skip_cleanup: true
22-
local_dir: dist
23-
on:
24-
branch: dev
25-
- provider: s3
26-
cache_control: private, no-store, no-cache, must-revalidate, max-age=0
27-
detect_encoding: true
28-
access_key_id: $QA_AWS_KEY
29-
secret_access_key: $QA_AWS_SECRET
30-
bucket: app.topcoder-qa.com
31-
skip_cleanup: true
32-
local_dir: dist
33-
on:
34-
branch: qa-integration
35-
- provider: s3
36-
cache_control: private, no-store, no-cache, must-revalidate, max-age=0
37-
access_key_id: $MASTER_AWS_KEY
38-
secret_access_key: $MASTER_AWS_SECRET
39-
bucket: app.topcoder.com
40-
skip_cleanup: true
41-
local_dir: dist
42-
on:
43-
branch: master
10+
- provider: s3
11+
cache_control: private, no-store, no-cache, must-revalidate, max-age=0
12+
detect_encoding: true
13+
access_key_id: $AWS_KEY
14+
secret_access_key: $AWS_SECRET
15+
bucket: app.topcoder-dev.com
16+
skip_cleanup: true
17+
local_dir: dist
18+
on:
19+
branch: dev
20+
- provider: s3
21+
cache_control: private, no-store, no-cache, must-revalidate, max-age=0
22+
detect_encoding: true
23+
access_key_id: $QA_AWS_KEY
24+
secret_access_key: $QA_AWS_SECRET
25+
bucket: app.topcoder-qa.com
26+
skip_cleanup: true
27+
local_dir: dist
28+
on:
29+
branch: qa-integration
30+
- provider: s3
31+
cache_control: private, no-store, no-cache, must-revalidate, max-age=0
32+
detect_encoding: true
33+
access_key_id: $MASTER_AWS_KEY
34+
secret_access_key: $MASTER_AWS_SECRET
35+
bucket: app.topcoder.com
36+
skip_cleanup: true
37+
local_dir: dist
38+
on:
39+
branch: master
4440
env:
4541
matrix:
4642
- CXX=g++-4.8
@@ -60,6 +56,9 @@ env:
6056
addons:
6157
apt:
6258
sources:
63-
- ubuntu-toolchain-r-test
59+
- ubuntu-toolchain-r-test
6460
packages:
65-
- g++-4.8
61+
- g++-4.8
62+
notifications:
63+
slack:
64+
secure: PMGlpdBoRzMlIjCsPWdXJ1wf550b+mpX0x44ggGWNL7ErpNebfyqIbXf4VJXYQDmhVJt31ygDaxTtj8XwZJlbvQjE6WGHU26KvL/efGJJL5EmgFD8LDBFpsbn49PyoZuVOTbSzqP8d8WCCPo4oBvX2r2Q2Ixh/tUx7i4Bcv0XwNpWAR75v1Yq/NftEI48k2GcI3oHqmuEgLHdP93k1rCUM4sBsgkr4PCltZfoE2AWlF6wY59w/oFiKj4FwycY8QjJZa/zbSQq1B/9QD7n4YBY4QjVv3LmjshEiQv1HGo2rNLV+/BB5ZoQ6JEH9h+seduHNTF+mkToKbJ2YjDERLlqLFYWVQKXTqFkSdYuknguJ3uOfXFaGtPDSqTRljE6WW6UDIJi9lDpxFHjH2q848/2O03RKtYeFKJWNbVb7Q2PWTBFxx6OurYra+tbUAorQiYmAQxd0vJY+qzGIDJZIQ8yDE4C10heOhfRyU8wJSKF3xJUKKWVGfBuHivFBZOETFSg0uVBcJnsXRcErvEQz0LuKaZfP81bIokcKUGxum/xyp9mYhYqWDvIj31RUhDMiRxXTPe9PhW0mlOtRG7tm2+8G08exHPSfONSV2IPUtlQt4j2/+I22ncOwtsm6yZzXXbDjoMR2sCHIyJj3lVECOqAnCfNJ6Q0CNJ93LqxKSHdFU=

README.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#### Dev [![Build Status](https://travis-ci.org/appirio-tech/topcoder-app.svg?branch=dev)](https://travis-ci.org/appirio-tech/topcoder-app) Master [![Build Status](https://travis-ci.org/appirio-tech/topcoder-app.svg?branch=master)](https://travis-ci.org/appirio-tech/topcoder-app)
1+
#### Dev [![Build Status](https://travis-ci.org/appirio-tech/topcoder-app.svg?branch=dev)](https://travis-ci.org/appirio-tech/topcoder-app) QA [![Build Status](https://travis-ci.org/appirio-tech/topcoder-app.svg?branch=qa-integration)](https://travis-ci.org/appirio-tech/topcoder-app) Master [![Build Status](https://travis-ci.org/appirio-tech/topcoder-app.svg?branch=master)](https://travis-ci.org/appirio-tech/topcoder-app)
22
# Topcoder-App
33

44
This repository houses any new topcoder pages or refactored Angular apps/pages from the tc-site repository.
@@ -13,11 +13,12 @@ Install dependencies by running the following in the root of the project:
1313
- `npm i`
1414
- **Note:** You must use npm 3. Type `npm -v` to ensure you have a 3.x version.
1515

16-
In order to test a logged in user, you must make an entry in your `/etc/hosts` file, pointing `local.topcoder-dev.com` to `localhost`. For example, open your `/etc/hosts` file with something like `vim /etc/hosts` and add `127.0.0.1 local.topcoder-dev.com`. After you run `gulp serve`, which launches a new window or tab, change `http://localhost:3000/sample/` to `http://local.topcoder-dev.com:3000/sample/`. You will then be able to login and pick up information from the cookies with `.topcoder-dev.com` as the domain.
16+
In order to test a logged in user, you must make an entry in your `/etc/hosts` file, pointing `local.topcoder-dev.com` to `localhost`. For example, open your `/etc/hosts` file with something like `vim /etc/hosts` and add `127.0.0.1 local.topcoder-dev.com`. After you run `gulp serve`, which launches a new window or tab, change `http://localhost:3000/login/` to `http://local.topcoder-dev.com:3000/login/`. You will then be able to login and pick up information from the cookies with `.topcoder-dev.com` as the domain.
1717

1818
## NPM Commands
19-
- To run locally: `npm run dev` and head to `local.topcoder-dev.com:3000/my-dashboard`
19+
- To run locally: `npm start` and head to `local.topcoder-dev.com:3000/login`
2020
- To create the build: `npm run build`
21+
- To run code linting: `npm run lint`
2122
- To run the tests: `npm test`
2223

2324
## Recommended Developer Tools
@@ -47,15 +48,16 @@ JavaScript linting
4748
- For new projects, you can create a local `.eslintrc.json` file by running `eslint --init`
4849
- **Note:** If you're using ES6, make sure you add `"modules": true` to `"ecmaFeatures"` and `"node": true` to `"env"` in your `.eslintrc.json` file
4950
- **Note:** If you are using React, make sure you have `eslint` and `eslint-plugin-react` as `devDependencies` in your `package.json` file
50-
- **Optional**: Add `"lint": "eslint ."` to your `package.json` file to run linting at any time via `npm run lint`
5151

5252
Automatic JavaScript linting in Sublime Text
5353
- Install [SublimeLinter](http://sublimelinter.readthedocs.org/en/latest/installation.html) following the instructions under "Installing via Package Control"
5454
- Install [SublimeLinter-eslint](https://github.com/roadhump/SublimeLinter-eslint) with the package manager. The package is called `SublimeLinter-contrib-eslint`
5555

5656
### Testing
5757

58-
To read about the file and folder structure of tests, read [this section](https://github.com/appirio-tech/topcoder-app#tests)
58+
The tests folder contains mock data (`tests/test-helpers/mock-data.js`). To run tests, use `npm test`.
59+
60+
Spec files live alongside the code they are testing. For example, in peer-review you have `review-status.controller.js` and `review-status.spec.js` in the same review-status folder.
5961

6062
### Description of Files and Folders
6163

@@ -73,11 +75,6 @@ Services live in their own folder. All services are part of the tc.services modu
7375
- Scripts
7476
- This folder contains our analytics, e.g. Google, New Relic, etc.
7577

76-
#### tests
77-
The tests folder contains mock data (`tests/test-helpers/mock-data.js`). To run tests, use `npm test`.
78-
79-
Spec files live alongside the code they are testing. For example, in peer-review you have `review-status.controller.js` and `review-status.spec.js` in the same review-status folder.
80-
8178
## UI-Router and States
8279
See any `*.routes.js` file as an example.
8380

@@ -87,8 +84,8 @@ See any `*.routes.js` file as an example.
8784

8885
### Style Guide and Naming Conventions
8986

87+
- Our travis build runs `npm run lint` and `npm test`, so make sure your code adheres to the code style enforced by our linters
9088
- Please use ES2015 syntax whenever possible
91-
- Do not use semicolons
9289
- Use the Angular style guide mentioned below
9390

9491
In general, follow this [AngularJS style guide](https://github.com/johnpapa/angular-styleguide), which covers JavaScript code style, JavaScript variable naming, and file naming conventions. One deviation is in the naming of services, where we follow the same pattern as controllers, e.g. UserService, ProfileService.

app/account/login/login.controller.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,15 @@ import angular from 'angular'
115115
return Helpers.redirectPostLogin($stateParams.next)
116116
})
117117
.catch(function(resp) {
118+
/*eslint no-fallthrough:0*/
118119
switch (resp.status) {
119-
case "ACCOUNT_INACTIVE":
120-
window.location.href = "https://www." + CONSTANTS.domain + "/account-inactive/"
121-
case "USER_NOT_REGISTERED":
122-
default:
123-
vm.socialLoginError = 401
124-
vm.loginErrors.SOCIAL_LOGIN_ERROR = true
125-
break
120+
case 'ACCOUNT_INACTIVE':
121+
window.location.href = 'https://www.' + CONSTANTS.domain + '/account-inactive/'
122+
case 'USER_NOT_REGISTERED':
123+
default:
124+
vm.socialLoginError = 401
125+
vm.loginErrors.SOCIAL_LOGIN_ERROR = true
126+
break
126127
}
127128
})
128129
}

app/account/login/login.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* jshint -W117, -W030 */
1+
/*eslint no-undef:0*/
22
describe('Login Controller', function() {
33
var controller
44
var scope

app/account/logout/logout.controller.spec.js renamed to app/account/logout/logout.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
/*eslint no-undef:0*/
12
import angular from 'angular'
23

3-
/* jshint -W117, -W030 */
44
describe('Logout Controller', function() {
55
var controller
66
var fakeWindow = {

app/account/register/register.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* jshint -W117, -W030 */
1+
/*eslint no-undef:0*/
22
describe('Register Controller', function() {
33
var controller
44

@@ -16,7 +16,7 @@ describe('Register Controller', function() {
1616
beforeEach(function() {
1717
var helperService = {
1818
getCountyObjFromIP: function() {
19-
return $q.when({name: "United States", alpha2: "US", alpha3: "USA", code: "840"})
19+
return $q.when({name: 'United States', alpha2: 'US', alpha3: 'USA', code: '840'})
2020
}
2121
}
2222

app/account/reset-password/reset-password.spec.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/* jshint -W117, -W030 */
1+
/*eslint no-undef:0*/
22
describe('Reset Password Controller', function() {
33
var controller
4-
var apiUrl = 'https://api.topcoder-dev.com/v3'
54

65
beforeEach(function() {
76
bard.appModule('topcoder')
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
import angular from 'angular'
2+
13
// Include in index.html so that app level exceptions are handled.
24
// Exclude from testRunner.html which should run exactly what it wants to run
35
(function () {
4-
'use strict';
6+
'use strict'
57

68
angular
79
.module('blocks.exception')
810
.provider('exceptionHandler', exceptionHandlerProvider)
9-
.config(config);
11+
.config(config)
1012

1113
/**
1214
* Must configure the exception handling
@@ -16,18 +18,18 @@
1618
/* jshint validthis:true */
1719
this.config = {
1820
appErrorPrefix: undefined
19-
};
21+
}
2022

2123
this.configure = function (appErrorPrefix) {
22-
this.config.appErrorPrefix = appErrorPrefix;
23-
};
24+
this.config.appErrorPrefix = appErrorPrefix
25+
}
2426

2527
this.$get = function () {
26-
return {config: this.config};
27-
};
28+
return {config: this.config}
29+
}
2830
}
2931

30-
config.$inject = ['$provide'];
32+
config.$inject = ['$provide']
3133

3234
/**
3335
* Configure by setting an optional string value for appErrorPrefix.
@@ -37,10 +39,10 @@
3739
* @ngInject
3840
*/
3941
function config($provide) {
40-
$provide.decorator('$exceptionHandler', extendExceptionHandler);
42+
$provide.decorator('$exceptionHandler', extendExceptionHandler)
4143
}
4244

43-
extendExceptionHandler.$inject = ['$delegate', 'exceptionHandler', 'logger'];
45+
extendExceptionHandler.$inject = ['$delegate', 'exceptionHandler', 'logger']
4446

4547
/**
4648
* Extend the $exceptionHandler service to also display a toast.
@@ -51,20 +53,20 @@
5153
*/
5254
function extendExceptionHandler($delegate, exceptionHandler, logger) {
5355
return function (exception, cause) {
54-
var appErrorPrefix = exceptionHandler.config.appErrorPrefix || '';
55-
var errorData = {exception: exception, cause: cause};
56-
exception.message = appErrorPrefix + exception.message;
57-
$delegate(exception, cause);
56+
var appErrorPrefix = exceptionHandler.config.appErrorPrefix || ''
57+
var errorData = {exception: exception, cause: cause}
58+
exception.message = appErrorPrefix + exception.message
59+
$delegate(exception, cause)
5860
/**
5961
* Could add the error to a service's collection,
6062
* add errors to $rootScope, log errors to remote web server,
6163
* or log locally. Or throw hard. It is entirely up to you.
62-
* throw exception;
64+
* throw exception
6365
*
6466
* @example
65-
* throw { message: 'error message we added' };
67+
* throw { message: 'error message we added' }
6668
*/
67-
logger.error(exception.message, errorData);
68-
};
69+
logger.error(exception.message, errorData)
70+
}
6971
}
70-
})();
72+
})()

app/blocks/exception/exception-handler.provider.spec.js

-67
This file was deleted.

0 commit comments

Comments
 (0)