Skip to content

Commit 5ba4127

Browse files
Rushabh SanchetiRushabh Sancheti
authored andcommitted
2 parents d317aef + 1018cc7 commit 5ba4127

File tree

10 files changed

+20
-11
lines changed

10 files changed

+20
-11
lines changed

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ FRONTEND_CLIENT_ID=bcJD0I08jykjwYBcxBGy
1313
FRONTEND_GRANT_TYPE=http://auth0.com/oauth/grant-type/password-realm
1414

1515
# AUTH0 api
16-
API_AUDIENCE = https://node-express-demo
16+
API_AUDIENCE = https://node-express-demo
17+
18+
REDIS_PORT=6379
19+
REDIS_DOMAIN=localhost

.env.test

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ FRONTEND_GRANT_TYPE=http://auth0.com/oauth/grant-type/password-realm
1414

1515
# AUTH0 api
1616
API_AUDIENCE =https://express-demo
17+
1718
ENVIRONMENT_NAME=test
18-
NODE_ENV=test
19+
NODE_ENV=test
20+
REDIS_PORT=6379
21+
REDIS_DOMAIN=localhost

jest.setup.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
require('dotenv').config({
2+
path: `.env.test`
3+
});
14
process.env.ENVIRONMENT_NAME = 'test';
25
beforeEach(() => {
36
process.env = { ...process.env, ENVIRONMENT_NAME: 'test' };
47
});
8+
59
afterEach(() => {
610
jest.clearAllMocks();
711
jest.resetAllMocks();

server/api/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import { mongoConnector } from 'middlewares/mongo';
1313

1414
import { customApisMapper, REQUEST_TYPES } from 'api/customApisMapper';
15-
import customRoutes from './routes/custom';
15+
import customRoutes from '../routes';
1616
import { isTestEnv } from 'utils';
1717

1818
/* istanbul ignore next */

server/api/tests/utils.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ describe('utils tests', () => {
7575
throw error;
7676
})
7777
};
78-
expect(() => fetchItems(model)).rejects.toThrow(error);
78+
expect(() => fetchItems(model, {})).rejects.toThrow(error);
7979
});
8080
});
8181

server/daos/order.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export const totalAmtForDate = async date => {
4848

4949
export const earliestCreatedDate = async () => {
5050
try {
51-
console.log('I GOT IT THIS FAR');
5251
const order = await Orders.findOne().sort({ createdAt: 1 }).limit(1);
5352

5453
return order.createdAt.toISOString().split('T')[0];

server/daos/tests/order.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('Order daos tests', () => {
5454
await totalAmtForDate(date);
5555
}).rejects.toThrow(mockError);
5656
});
57-
it('should return total amount as 0 for the day', async () => {
57+
it('should return total amount as 0 for the day as no order is placed on that day', async () => {
5858
mockingoose(model).toReturn([], 'aggregate');
5959
const res = await totalAmtForDate(date);
6060
expect(res).toBe(0);
@@ -88,7 +88,7 @@ describe('Order daos tests', () => {
8888
await totalByDateForCategory(date, category);
8989
}).rejects.toThrow(mockError);
9090
});
91-
it('should return total amt as 0 for the day for a category', async () => {
91+
it('should return total amt as 0 for the day for a category as no order is placed for that category on that day', async () => {
9292
mockingoose(model).toReturn([], 'aggregate');
9393
const res = await totalByDateForCategory(date, category);
9494
expect(res).toBe(0);
@@ -109,7 +109,7 @@ describe('Order daos tests', () => {
109109
}).rejects.toThrow(mockError);
110110
});
111111

112-
it('should return the total count of order as 0 for the day', async () => {
112+
it('should return the total count of order as 0 for the day as no order is placed on that date', async () => {
113113
mockingoose(model).toReturn([], 'aggregate');
114114
const res = await countByDate(date);
115115
expect(res).toBe(0);
@@ -130,7 +130,7 @@ describe('Order daos tests', () => {
130130
}).rejects.toThrow(mockError);
131131
});
132132

133-
it('should return count for the day for a category as 0', async () => {
133+
it('should return count for the day for a category as 0 as no order was placed for that category on that day', async () => {
134134
mockingoose(model).toReturn([], 'aggregate');
135135
const res = await countByDateForCategory(date, category);
136136
expect(res).toBe(0);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { roles, roleValidator } from 'api/roles';
44
import { assignRoles, assignRoleValidator } from 'api/assignRoles';
55
import { cronJob, cronJobValidator } from 'api/cronJob';
66
import { createOrder, orderValidator } from 'api/orders';
7-
import checkJwt from 'middlewares/Authenticate';
7+
import checkJwt from 'middlewares/authenticate';
88
import checkRole from 'middlewares/checkRole';
99
import limiter from 'middlewares/rateLimiter';
1010

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7284,7 +7284,7 @@ superagent@^5.1.1:
72847284
readable-stream "^3.6.0"
72857285
semver "^7.3.2"
72867286

7287-
superagent@^7.0.2:
7287+
superagent@^7.1.0:
72887288
version "7.1.2"
72897289
resolved "https://registry.yarnpkg.com/superagent/-/superagent-7.1.2.tgz#71393141edd086ccf2544a29a4a609e46b7911f3"
72907290
integrity sha512-o9/fP6dww7a4xmEF5a484o2rG34UUGo8ztDlv7vbCWuqPhpndMi0f7eXxdlryk5U12Kzy46nh8eNpLAJ93Alsg==

0 commit comments

Comments
 (0)