Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ New version of Topcoder Community website.

*Disclaimer:* Current instructions are biased towards Ubuntu 16.04. Hovewer, similar recipies should work for other OS. Should you encounter and overcome any tricky issues on other OS, you are welcome to add notes/hints into this file.

1. You should have NodeJS 6.10.0 (other recent versions should also work fine);
1. You should have NodeJS 6.10.2 (other recent versions should also work fine);

2. Install dependencies with one of the following commands:
- `$ npm install` Installs all dependencies. Recommended for local development;
Expand Down
28 changes: 14 additions & 14 deletions __tests__/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ describe('Api test', () => {
server = require(MODULE).default;
});
test('post to /api/logger', () => request(server).post('/api/logger')
.send({ data: 'data' })
.then((response) => {
expect(response.statusCode).toBe(200);
}));
.send({ data: 'data' })
.then((response) => {
expect(response.statusCode).toBe(200);
}));
test('post to /api/xml2json', () => request(server).post('/api/xml2json')
.send({ xml: '<xml></xml>' })
.then((response) => {
expect(response.text).toBe('{"xml":{}}');
}));
.send({ xml: '<xml></xml>' })
.then((response) => {
expect(response.text).toBe('{"xml":{}}');
}));
test('status 404', () => request(server).get('/ELB-HealthChecker/2.0')
.then((response) => {
expect(response.statusCode).toBe(404);
}));
.then((response) => {
expect(response.statusCode).toBe(404);
}));
test('status 500', () => request(server).post('/api/logger')
.then((response) => {
expect(response.statusCode).toBe(500);
}));
.then((response) => {
expect(response.statusCode).toBe(500);
}));
test('status 500 Internal Error', () => {
process.env.NODE_ENV = 'development';
jest.resetModules();
Expand Down
18 changes: 9 additions & 9 deletions __tests__/server/tc-communities.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ describe('tc-communities api test', () => {
server = require(MODULE).default;
});
test('get community filter', () => request(server).get('/api/tc-communities')
.then((response) => {
expect(response.statusCode).toBe(200);
}));
.then((response) => {
expect(response.statusCode).toBe(200);
}));
test('get community meta', () => request(server).get('/api/tc-communities/wipro/meta')
.then((response) => {
expect(response.statusCode).toBe(200);
}));
.then((response) => {
expect(response.statusCode).toBe(200);
}));
test('get non-exist community meta', () => request(server).get('/api/tc-communities/noop/meta')
.then((response) => {
expect(response.statusCode).toBe(404);
}));
.then((response) => {
expect(response.statusCode).toBe(404);
}));
});
31 changes: 18 additions & 13 deletions __tests__/shared/actions/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,48 +21,53 @@ afterAll(() => {
});

describe('challenge.fetchChallengeInit', () => {
const a = actions.fetchChallengeInit();
const a = actions.challenge.getDetailsInit(12345);

test('has expected type', () => {
expect(a.type).toBe('FETCH_CHALLENGE_INIT');
expect(a.type).toBe('CHALLENGE/GET_DETAILS_INIT');
});

test('payload is undefined', () =>
expect(a.payload).toBeUndefined());
test('payload is the challenge ID, converted to string, if necessary', () =>
expect(a.payload).toBe('12345'));
});

describe('challenge.fetchSubmissionsInit', () => {
const a = actions.fetchSubmissionsInit();
const a = actions.challenge.getSubmissionsInit();

test('has expected type', () => {
expect(a.type).toBe('FETCH_SUBMISSIONS_INIT');
expect(a.type).toBe('CHALLENGE/GET_SUBMISSIONS_INIT');
});

test('payload is undefined', () =>
expect(a.payload).toBeUndefined());
});

describe('challenge.fetchChallengeDone', () => {
describe('challenge.getDetailsDone', () => {
global.fetch = mockFetch({ result: { content: ['DUMMY DATA'] } });

const a = actions.fetchChallengeDone({});
const a = actions.challenge.getDetailsDone(12345);

test('has expected type', () => {
expect(a.type).toBe('FETCH_CHALLENGE_DONE');
expect(a.type).toBe('CHALLENGE/GET_DETAILS_DONE');
});

test('payload is a promise which resolves to the expected object', () =>
a.payload.then(res => expect(res).toEqual('DUMMY DATA')));
/* TODO: This test does not work anymore, as the action was refactored to
* use challenges service for API v3 calls, while API v2 calls still happen
* the way they used to. Thus, we need a better mock of fetch to test it,
* or some alternative approach. */
test.skip('payload is a promise which resolves to the expected object', () =>
a.payload.then(res => expect(res).toEqual(
['DUMMY DATA', { result: { content: ['DUMMY DATA'] } }, {}])));
});


describe('challenge.fetchSubmissionsDone', () => {
global.fetch = mockFetch({ submissions: 'DUMMY DATA' });

const a = actions.fetchSubmissionsDone({});
const a = actions.challenge.getSubmissionsDone({});

test('has expected type', () => {
expect(a.type).toBe('FETCH_SUBMISSIONS_DONE');
expect(a.type).toBe('CHALLENGE/GET_SUBMISSIONS_DONE');
});

test('payload is a promise which resolves to the expected object', () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ exports[`Snapshot match 1`] = `
>
<a
className="tc-btn-sm tc-btn-primary"
href="https://accounts.topcoder-dev.com/member/registration"
href="http://accounts-test.topcoder-dev.com/member/registration"
>
Join
</a>
<a
className="tc-btn-sm tc-btn-default"
href="https://accounts.topcoder-dev.com/member"
href="http://accounts-test.topcoder-dev.com/member"
>
Log In
</a>
Expand All @@ -25,13 +25,13 @@ exports[`Snapshot match 2`] = `
>
<a
className="tc-btn-sm tc-btn-primary"
href="https://accounts.topcoder-dev.com/member/registration"
href="http://accounts-test.topcoder-dev.com/member/registration"
>
Join
</a>
<a
className="tc-btn-sm tc-btn-default"
href="https://accounts.topcoder-dev.com/member"
href="http://accounts-test.topcoder-dev.com/member"
>
Log In
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ exports[`Default render 1`] = `
>
<a
className="tc-btn-sm tc-btn-primary"
href="https://accounts.topcoder-dev.com/member/registration"
href="http://accounts-test.topcoder-dev.com/member/registration"
>
Join
</a>
<a
className="tc-btn-sm tc-btn-default"
href="https://accounts.topcoder-dev.com/member"
href="http://accounts-test.topcoder-dev.com/member"
>
Log In
</a>
Expand Down Expand Up @@ -232,13 +232,13 @@ exports[`Render with open menu 1`] = `
>
<a
className="tc-btn-sm tc-btn-primary"
href="https://accounts.topcoder-dev.com/member/registration"
href="http://accounts-test.topcoder-dev.com/member/registration"
>
Join
</a>
<a
className="tc-btn-sm tc-btn-default"
href="https://accounts.topcoder-dev.com/member"
href="http://accounts-test.topcoder-dev.com/member"
>
Log In
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const mockDatas = [{
expanded: true,
expand,
challenges: [
{ id: '1', status: 'b' },
{ id: '1', status: 'b' },
{
id: '2',
status: 'a',
Expand Down
Loading