diff --git a/test/ad.test.js b/test/ad.test.js index 3610760e9cad39bdc06761d5f7324d1740c77f9d..df715824fc5728cbabdaa237a00451d98ead5b72 100644 --- a/test/ad.test.js +++ b/test/ad.test.js @@ -359,39 +359,41 @@ describe('Ad Routes', () => { describe('Query graphQl : getAds and getAd By Id', () => { it('should return a list of ads', async () => { const query = ` - query { - getAds(token: "${agent1AuthToken}") { - _id - title - propertyType - publicationStatus - propertyStatus - description - price - availabilityDate - photos - userName - questions { - user - question - } + query { + getAds { + _id + title + propertyType + publicationStatus + propertyStatus + description + price + availabilityDate + photos + userName + questions { + user + question } } - `; + } + `; - const response = await chai - .request(app) - .post('/graphql') - .send({ query }); + const response = await chai + .request(app) + .post('/graphql') + .set('Authorization', `Bearer ${agent1AuthToken}`) + .send({ query }); - expect(response).to.have.status(200); - expect(response.body).to.have.property('data'); - expect(response.body.data).to.have.property('getAds'); + expect(response).to.have.status(200); + expect(response.body).to.have.property('data'); + expect(response.body.data).to.have.property('getAds'); }); + it('should return details of a specific ad', async () => { const query = ` query { - getAdById(adId: "${adId}", token: "${agent2AuthToken}") { + getAdById(adId: "${adId}") { _id title propertyType @@ -413,6 +415,7 @@ describe('Ad Routes', () => { const response = await chai .request(app) .post('/graphql') + .set('Authorization', `Bearer ${agent2AuthToken}`) .send({ query }); expect(response).to.have.status(200); @@ -421,6 +424,7 @@ describe('Ad Routes', () => { }); }); + describe('Mutation: addAd', () => { it('Adds a new ad and returns the correct fields', async () => { const variables = { diff --git a/test/user.test.js b/test/user.test.js index 292623967baf9a35731f69a56b32fcb198c53a57..8fe9dac0335f72357b05fe822934761b44d5ee23 100644 --- a/test/user.test.js +++ b/test/user.test.js @@ -8,7 +8,7 @@ const mongoose = require('mongoose'); chai.use(chaiHttp); let testUserToken; -/*describe('Authentication Routes', () => { +describe('Authentication Routes', () => { describe('POST /user', () => { it('should create a new user', (done) => { chai @@ -84,4 +84,4 @@ let testUserToken; await mongoose.connection.close(); } }); -});*/ +});