diff --git a/__tests__/appRoutes.js b/__tests__/appRoutes.js new file mode 100644 index 0000000..b80e05c --- /dev/null +++ b/__tests__/appRoutes.js @@ -0,0 +1,33 @@ +const request = require('supertest') +const app = require('../app') + +describe('Post new application', () => { + it('should create a new application', async () => { + const res = await request(app.callback()) + .post('/api/v1/applications/all') + .send({ + firstName: 'random_11223', + lastName: 'guy_1222', + email: 'random@example.com', + address: '32 Mane Road' + }) + expect(res.statusCode).toEqual(201) + expect(res.body).toHaveProperty('created', true) + }) +}); + +describe('Get all applications', () => { + it('should show all applications', async () => { + const res = await request(app.callback()) + .get('/api/v1/applications/all') + expect(res.statusCode).toEqual(200) + }) +}); + +describe('Get all users', () => { + it('should show all users', async () => { + const res = await request(app.callback()) + .get('/api/v1/users') + expect(res.statusCode).toEqual(401) + }) +}); \ No newline at end of file diff --git a/__tests__/check_jest_works.js b/__tests__/check_jest_works.js index 6ead8f5..feca1a6 100644 --- a/__tests__/check_jest_works.js +++ b/__tests__/check_jest_works.js @@ -3,12 +3,3 @@ test('Jest should use the test DB', ()=> { expect(process.env.DB_DATABASE).toBe('test_db'); }) -// This test fails because 1 !== 2 -xit('Testing to see if Jest works', () => { - expect(1).toBe(2) - }) - -// This passes because 1 === 1 -xit('Testing to see if Jest works 2', () => { - expect(1).toBe(1) - }) diff --git a/__tests__/userRoutes.js b/__tests__/userRoutes.js index 013b917..d4482a9 100644 --- a/__tests__/userRoutes.js +++ b/__tests__/userRoutes.js @@ -20,6 +20,14 @@ describe('Get all users', () => { it('should show all users', async () => { const res = await request(app.callback()) .get('/api/v1/users') + expect(res.statusCode).toEqual(401) + }) +}); + +describe('Get all applications', () => { + it('should show all applications', async () => { + const res = await request(app.callback()) + .get('/api/v1/applications/all') expect(res.statusCode).toEqual(200) }) });