Skip to content

Commit

Permalink
Test: features
Browse files Browse the repository at this point in the history
  • Loading branch information
betiniakarandut committed Oct 20, 2023
1 parent 2735b91 commit 8c12155
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions server/test/routes/offers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ describe('test offer endpoints', () => {

const offer = new OfferModel(offerData);
await offer.save();
});
}, 10000);
beforeEach(async () => {
app = express();
await app.use(express.json());
await app.use('/offers', offerRoutes);
});
}, 10000);
afterAll(async () => {
await dropDB();
await disconnectDB();
});
}, 10000);

it('test get all offers /offers', async () => {
const res: GenericResponse<ResponseDocument, string> =
Expand All @@ -40,5 +40,5 @@ describe('test offer endpoints', () => {
expect(JSON.parse(res.text)).toHaveProperty('links');
expect(JSON.parse(res.text)['offers']).toBeInstanceOf(Array);
expect(JSON.parse(res.text)['offers'][0]).toHaveProperty('_id');
});
}, 10000);
});
18 changes: 9 additions & 9 deletions server/test/routes/talentControllers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ dotenv.config();

beforeAll(async () => {
await connectDB();
});
}, 10000);

afterAll(async () => {
await dropDB();
await disconnectDB();
});
}, 10000);

describe('Authentication TalentController Tests', () => {
let app;
beforeEach(async () => {
app = express();
await app.use(express.json());
await app.use('/talents', talentRoutes);
});
}, 10000);
beforeAll(async () => {
const talentData = {
name: 'Test User',
Expand All @@ -33,7 +33,7 @@ describe('Authentication TalentController Tests', () => {

const talent = new Talent(talentData);
await talent.save();
});
}, 10000);

it('should sign up a new talent', async () => {
const res = await request(app).post('/talents/signup').send({
Expand All @@ -43,7 +43,7 @@ describe('Authentication TalentController Tests', () => {
});
expect(JSON.parse(res.text)).toHaveProperty('token');
expect(JSON.parse(res.text)).toHaveProperty('newTalent');
});
}, 10000);

it('should prevent signing up with an existing email', async () => {
const res = await request(app)
Expand All @@ -55,10 +55,10 @@ describe('Authentication TalentController Tests', () => {
.expect(400);

expect(JSON.parse(res.text)).toHaveProperty(
'message',
'Message',
'Email already in use'
);
});
}, 10000);

it('should sign in a user', async () => {
const res = await request(app)
Expand All @@ -68,7 +68,7 @@ describe('Authentication TalentController Tests', () => {

expect(JSON.parse(res.text)).toHaveProperty('token');
expect(JSON.parse(res.text)).toHaveProperty('talent');
});
}, 10000);

it('should prevent signing in with invalid credentials', async () => {
const res = await request(app)
Expand All @@ -80,5 +80,5 @@ describe('Authentication TalentController Tests', () => {
'message',
'Invalid credentials'
);
});
},10000);
});

0 comments on commit 8c12155

Please sign in to comment.