Skip to content

Commit

Permalink
Merge 00ffd7d into 5d0c5f6
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-vr committed Jan 30, 2019
2 parents 5d0c5f6 + 00ffd7d commit c0ff2e3
Show file tree
Hide file tree
Showing 18 changed files with 6,963 additions and 8,095 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {
"json"
],
transform: {
"\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
"\\.(ts|tsx)$": "ts-jest"
},
testRegex: "/tests/.*\\.(ts|tsx|js)$",
setupFiles: ["<rootDir>/tests/test.config.ts"],
Expand Down
14,855 changes: 6,864 additions & 7,991 deletions package-lock.json

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,55 +24,55 @@
],
"dependencies": {
"@sentry/node": "~4.5.3",
"camelcase-keys": "~4.2.0",
"connect-redis": "~3.3.3",
"dotenv-safe": "~6.0.0",
"express": "~4.16.2",
"http-status": "~1.2.0",
"joi": "~13.5.2",
"jsonade": "~1.3.0",
"knex": "~0.15.2",
"lodash": "~4.17.10",
"camelcase-keys": "~5.0.0",
"connect-redis": "~3.4.0",
"dotenv-safe": "~6.1.0",
"express": "~4.16.4",
"http-status": "~1.3.1",
"joi": "~14.3.1",
"jsonade": "~1.4.0",
"knex": "~0.16.3",
"lodash": "~4.17.11",
"mandrill-api": "~1.0.45",
"pg": "~7.4.3",
"pg": "~7.8.0",
"redis": "~2.8.0",
"tree-house": "~3.3.0",
"tree-house-authentication": "~2.2.1",
"tree-house-errors": "~1.2.0",
"tree-house-translations": "~1.1.0",
"tree-house": "~3.3.2",
"tree-house-authentication": "~3.0.0",
"tree-house-errors": "~1.2.1",
"tree-house-translations": "~1.1.2",
"uuid": "~3.3.2",
"winston": "~3.0.0"
"winston": "~3.2.1"
},
"devDependencies": {
"@types/cors": "~2.8.4",
"@types/dotenv-safe": "~5.0.0",
"@types/express": "~4.16.0",
"@types/dotenv-safe": "~5.0.3",
"@types/express": "~4.16.1",
"@types/express-brute": "~0.0.37",
"@types/express-session": "^1.15.11",
"@types/faker": "~4.1.2",
"@types/helmet": "~0.0.38",
"@types/express-session": "~1.15.11",
"@types/faker": "^4.1.5",
"@types/helmet": "~0.0.42",
"@types/http-status": "~0.2.30",
"@types/jest": "~23.3.1",
"@types/joi": "~13.4.0",
"@types/knex": "~0.14.19",
"@types/lodash": "~4.14.115",
"@types/jest": "^23.3.13",
"@types/joi": "~14.3.0",
"@types/knex": "~0.15.1",
"@types/lodash": "~4.14.120",
"@types/mandrill-api": "~1.0.30",
"@types/redis": "~2.8.6",
"@types/supertest": "~2.0.5",
"@types/uuid": "~3.4.3",
"@types/winston": "~2.3.9",
"auditjs": "^2.4.5",
"@types/redis": "~2.8.10",
"@types/supertest": "^2.0.7",
"@types/uuid": "~3.4.4",
"@types/winston": "~2.4.4",
"auditjs": "^3.0.10",
"coveralls": "^3.0.2",
"faker": "^4.1.0",
"jest": "^23.4.2",
"node-mocks-http": "^1.7.0",
"jest": "^24.0.0",
"node-mocks-http": "^1.7.3",
"pre-commit": "^1.2.2",
"rimraf": "^2.6.2",
"supertest": "^3.1.0",
"ts-jest": "~23.0.1",
"tslint": "^5.11.0",
"tslint-config-airbnb": "^5.9.2",
"typescript": "^3.0.1"
"rimraf": "^2.6.3",
"supertest": "^3.4.2",
"ts-jest": "^23.10.5",
"tslint": "^5.12.1",
"tslint-config-airbnb": "^5.11.1",
"typescript": "^3.2.4"
},
"engines": {
"node": ">=8"
Expand Down
2 changes: 1 addition & 1 deletion src/config/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as path from 'path';

// Read package.json on init
const root = path.resolve(__dirname, '..', '..');
const contents: any = fs.readFileSync(root + '/package.json');
const contents: any = fs.readFileSync(`${root}/package.json`);
let pjson: PJson = {};
if (contents) {
pjson = JSON.parse(contents);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/translator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as icappsTranslation from 'tree-house-translations';
import { existsSync, mkdirSync } from 'fs';

const defaultOptions = <any> {
destination: process.cwd() + '/locales',
destination: `${process.cwd()}/locales`,
clean: true,
seperateCategories: false,
exportType: 'json',
Expand Down
2 changes: 1 addition & 1 deletion tests/_helpers/mockdata/auth.data.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as request from 'supertest';
import { createJwt } from 'tree-house-authentication';
import { jwtConfig } from '../../../src/config/auth.config';
import { adminUser, inactiveUser, createUser, unconfirmedUser } from './user.data';
import { adminUser, createUser } from './user.data';
import { User, UserCreate } from '../../../src/models/user.model';
import { app } from '../../../src/app';

Expand Down
4 changes: 2 additions & 2 deletions tests/_helpers/mockdata/meta.data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Code, CodeCreate } from '../../../src/models/code.model';
import { CodeType, CodeTypeCreate } from '../../../src/models/code-type.model';
import { CodeCreate } from '../../../src/models/code.model';
import { CodeTypeCreate } from '../../../src/models/code-type.model';
import { tableNames } from '../../../src/constants';
import { db } from '../../../src/lib/db';
import * as metaRepository from '../../../src/repositories/meta.repository';
Expand Down
26 changes: 13 additions & 13 deletions tests/integration/auth.route.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as faker from 'faker';
import * as httpStatus from 'http-status';
import * as Joi from 'joi';
import * as request from 'supertest';
import { app } from '../../src/app';
import { errors } from '../../src/config/errors.config';
import * as mailer from '../../src/lib/mailer';
import { getValidJwt, getUserSessionToken } from '../_helpers/mockdata/auth.data';
import { getUserSessionToken } from '../_helpers/mockdata/auth.data';
import { clearAll } from '../_helpers/mockdata/data';
import { adminUser, createUser, findById, regularUser, setResetPwToken, unconfirmedUser, createUsers, removeUser } from '../_helpers/mockdata/user.data';
import { adminUser, createUser, findById, regularUser, setResetPwToken, unconfirmedUser, createUsers, removeUser }
from '../_helpers/mockdata/user.data';
import { loginSchema } from '../_helpers/payload-schemes/auth.schema';

describe('/auth', () => {
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('/auth', () => {
});

it('Should throw error when invalid email is provided', async () => {
const { body, status } = await request(app)
const { status } = await request(app)
.post(`${prefix}/auth/login`)
.send({
email: 'noValidEmail',
Expand All @@ -87,7 +87,7 @@ describe('/auth', () => {
});

it('Should throw error when invalid user is provided', async () => {
const { body, status } = await request(app)
const { status } = await request(app)
.post(`${prefix}/auth/login`)
.send({
email: 'fakeuser@icapps.com',
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('/auth', () => {
});

it('Should throw error when no email or password is provided', async () => {
const { body, status } = await request(app)
const { status } = await request(app)
.post(`${prefix}/auth/login/jwt`)
.send({
email: regularUser.email,
Expand All @@ -180,7 +180,7 @@ describe('/auth', () => {
});

it('Should throw error when invalid email is provided', async () => {
const { body, status } = await request(app)
const { status } = await request(app)
.post(`${prefix}/auth/login/jwt`)
.send({
email: 'noValidEmail',
Expand All @@ -202,7 +202,7 @@ describe('/auth', () => {
expect(body.errors[0].detail).toEqual(errors.USER_INVALID_CREDENTIALS.message);
});
it('Should throw error when invalid user is provided', async () => {
const { body, status } = await request(app)
const { status } = await request(app)
.post(`${prefix}/auth/login/jwt`)
.send({
email: 'fakeuser@icapps.com',
Expand Down Expand Up @@ -369,7 +369,7 @@ describe('/auth', () => {
});

it('Should throw an error when no token is provided', async () => {
const { body, status } = await request(app)
const { status } = await request(app)
.get(`${prefix}/forgot-password/verify`);
expect(status).toEqual(httpStatus.BAD_REQUEST);
});
Expand All @@ -396,7 +396,7 @@ describe('/auth', () => {
expect(updatedUser.status.code).toEqual('ACTIVE');

// Try to login with changed password
const { body: body2, status: status2 } = await request(app)
const { status: status2 } = await request(app)
.post(`${prefix}/auth/login`)
.send({
email: newUser.email,
Expand All @@ -406,8 +406,8 @@ describe('/auth', () => {
});

it('Should throw an error when the token is invalid', async () => {
const token = await setResetPwToken(users.regular.id);
const { body, status } = await request(app)
await setResetPwToken(users.regular.id);
const { status } = await request(app)
.put(`${prefix}/forgot-password/confirm?token=invalidToken`)
.send({ password: 'newPassword123' });

Expand All @@ -416,7 +416,7 @@ describe('/auth', () => {

it('Should throw an error when no password is provided', async () => {
const token = await setResetPwToken(users.regular.id);
const { body, status } = await request(app)
const { status } = await request(app)
.put(`${prefix}/forgot-password/confirm?token=${token}`);
expect(status).toEqual(httpStatus.BAD_REQUEST);
});
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/config.route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('/config', () => {
});

it('Should throw an error when an invalid os is provided', async () => {
const { body, status } = await request(app)
const { status } = await request(app)
.get(`${prefix}/version/unknown`);
expect(status).toEqual(httpStatus.BAD_REQUEST);
});
Expand Down
23 changes: 11 additions & 12 deletions tests/integration/meta.route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { adminUser, createUsers, regularUser } from '../_helpers/mockdata/user.d
import { codeByIdSchema, codesSchema, createCodeSchema } from '../_helpers/payload-schemes/meta.schema';

describe('/meta', () => {
const prefix = `/api/${process.env.API_VERSION}`;

const users = { regular: null, admin: null };
const tokens = { regular: null, admin: null };

Expand Down Expand Up @@ -154,7 +154,7 @@ describe('/meta', () => {
});

it('Should throw an error when code type is not found', async () => {
const { body, status } = await request(app)
const { status } = await request(app)
.get(`${prefix}/meta/codesByType/unknownType`)
.set('Authorization', `Bearer ${tokens.regular}`);

Expand All @@ -165,15 +165,14 @@ describe('/meta', () => {
describe('GET /codesByType/:codeType/all', () => {
const prefix = `/api/${process.env.API_VERSION}`;
let codeType;
let languageCodes;

beforeAll(async () => {
codeType = await createCodeType({ code: 'LAN', name: 'Language' });
const code1 = await createCode(codeType.id, { name: 'English', code: 'EN', deprecated: true });
const code2 = await createCode(codeType.id, { name: 'Nederlands', code: 'NL' });
const code3 = await createCode(codeType.id, { name: 'French', code: 'FR' });
const code4 = await createCode(codeType.id, { name: 'Weutelen', code: 'WEUTELS' });
languageCodes = [code1, code2, code3, code4];
await createCode(codeType.id, { name: 'English', code: 'EN', deprecated: true });
await createCode(codeType.id, { name: 'Nederlands', code: 'NL' });
await createCode(codeType.id, { name: 'French', code: 'FR' });
await createCode(codeType.id, { name: 'Weutelen', code: 'WEUTELS' });

});

afterAll(async () => {
Expand Down Expand Up @@ -242,14 +241,14 @@ describe('/meta', () => {
});
});
it('Should throw an error when code id is not a valid guid', async () => {
const { body, status } = await request(app)
const { status } = await request(app)
.get(`${prefix}/meta/codes/unknownId`)
.set('Authorization', `Bearer ${tokens.admin}`);
expect(status).toEqual(httpStatus.BAD_REQUEST);
});

it('Should throw an error when code does not exist', async () => {
const { body, status } = await request(app)
const { status } = await request(app)
.get(`${prefix}/meta/codes/${faker.random.uuid()}`)
.set('Authorization', `Bearer ${tokens.admin}`);
expect(status).toEqual(httpStatus.NOT_FOUND);
Expand Down Expand Up @@ -306,7 +305,7 @@ describe('/meta', () => {
});

it('Should throw an error when code type is not found', async () => {
const { body, status } = await request(app)
const { status } = await request(app)
.post(`${prefix}/meta/codes/unknownType`)
.set('Authorization', `Bearer ${tokens.admin}`)
.send({
Expand Down Expand Up @@ -429,7 +428,7 @@ describe('/meta', () => {
});

it('Should validate that there is at least 1 field to update', async () => {
const { body, status } = await request(app)
const { status } = await request(app)
.patch(`${prefix}/meta/codes/${code.id}`)
.set('Authorization', `Bearer ${tokens.admin}`);

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/personal.route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('/me', () => {

it('Should throw an error when user does not exist', async () => {
const token = await getValidJwt(faker.random.uuid());
const { body, status } = await request(app)
const { status } = await request(app)
.get(`${prefix}/me`)
.set('Authorization', `Bearer ${token}`);
expect(status).toEqual(httpStatus.NOT_FOUND);
Expand Down Expand Up @@ -87,7 +87,7 @@ describe('/me', () => {

it('Should throw an error when user does not exist', async () => {
const token = await getValidJwt(faker.random.uuid());
const { body, status } = await request(app)
const { status } = await request(app)
.put(`${prefix}/me`)
.set('Authorization', `Bearer ${token}`);
expect(status).toEqual(httpStatus.NOT_FOUND);
Expand Down

0 comments on commit c0ff2e3

Please sign in to comment.