Skip to content

Commit

Permalink
get projects testing
Browse files Browse the repository at this point in the history
relates #12
  • Loading branch information
rehabas committed Mar 31, 2020
1 parent fcfd644 commit 7dbac7f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error"
"jest/valid-expect": "error",
"consistent-return":"off",
"jest/no-test-callback":"off"
}
}
4 changes: 2 additions & 2 deletions server/controllers/routes/user/project/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { getProjectData } = require('./getProjectsData');
const { getProjectsData } = require('./getProjectsData');

module.exports = {
getProjectData,
getProjectsData,
};
2 changes: 1 addition & 1 deletion server/database/queries/project/getProjects.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const connection = require('../../config/connection');

exports.getCohort = () => connection.query('SELECT * FROM project');
exports.getProjects = () => connection.query('SELECT * FROM project');
23 changes: 21 additions & 2 deletions test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
test('Initial test', () => {
expect(1).toBe(1);
const request = require('supertest');
const connection = require('../server/database/config/connection');
const dbBuild = require('../server/database/config/build');

const app = require('../server/app');

beforeAll(() => dbBuild());

afterAll(() => connection.end());

test('Get projects route', (done) => {
request(app)
.get('/api/v1/projects')
.expect(200)
.expect('Content-Type', /json/)
.end(async (err, res) => {
const { data } = res.body;
if (err) return done(err);
expect(data).toHaveLength(2);
done();
});
});

0 comments on commit 7dbac7f

Please sign in to comment.