Skip to content

Commit 038a89b

Browse files
committed
working tests is back
1 parent 50545f1 commit 038a89b

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

tests/db/collections.test.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import {getRecords} from 'Components/db';
22
import config from 'Config';
33

4-
if (process.env.NODE_ENV == 'test') require('dotenv').config();
4+
require('dotenv').config();
55

66
describe('db tests', () => {
7-
test('do search and find records', async () => {
8-
console.log(process.env);
9-
console.log(process.env.CODEMASH_SECRET_KEY);
10-
console.log(process.env.CODEMASH_PROJECT_ID);
11-
7+
beforeEach(() => {
128
config.init(
139
{
14-
secretKey: 'GGzMupRM7upe9HPsZnrtWeOx-0AMF9UI',
15-
projectId: 'fe964bc0-3475-4ac2-81a9-2a3abdaf614b',
10+
secretKey: process.env.CODEMASH_SECRET_KEY,
11+
projectId: process.env.CODEMASH_PROJECT_ID,
1612
},
1713
process.env.NODE_ENV
1814
);
15+
});
16+
17+
test('do search and find records', async () => {
1918
const request = {collectionName: 'contacts'};
2019
const response = await getRecords(request);
2120
expect(response.totalCount).toBe(2);

tests/files/files.test.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import {uploadFile} from 'Components/files';
22
import config from 'Config';
33

4-
if (process.env.NODE_ENV == 'test') require('dotenv').config();
4+
require('dotenv').config();
55

66
var FormData = require('form-data');
77
const fs = require('fs');
88

99
describe('file tests', () => {
10-
beforeEach(() => {});
11-
12-
test('upload file as base 64', async () => {
10+
beforeEach(() => {
1311
config.init(
1412
{
15-
secretKey: 'GGzMupRM7upe9HPsZnrtWeOx-0AMF9UI',
16-
projectId: 'fe964bc0-3475-4ac2-81a9-2a3abdaf614b',
13+
secretKey: process.env.CODEMASH_SECRET_KEY,
14+
projectId: process.env.CODEMASH_PROJECT_ID,
1715
},
1816
process.env.NODE_ENV
1917
);
18+
});
2019

20+
test('upload file as base 64', async () => {
2121
const txtFile = fs.readFileSync('tests/files/uploads/document.txt', {
2222
encoding: 'base64',
2323
});
@@ -32,14 +32,6 @@ describe('file tests', () => {
3232
});
3333

3434
test('upload file', async () => {
35-
config.init(
36-
{
37-
secretKey: process.env.CODEMASH_SECRET_KEY,
38-
projectId: process.env.CODEMASH_PROJECT_ID,
39-
},
40-
process.env.NODE_ENV
41-
);
42-
4335
const txtFile = fs.createReadStream('tests/files/uploads/document.txt');
4436

4537
const request = {

0 commit comments

Comments
 (0)