lundi 19 septembre 2016

In sailsJS test POST request from Supertest not hitting function defined for route

My Project is on SailsJS. I am not using SailsJS Model. Data Controller is defined in /api/DataController. The routes to the Data Controllers are defined in config/routes.js. I am testing Data Controllers using Supertest.

The problem I am facing is when I test GET call to my route /api/1/drives the function works but when I do POST or PUT request to the route the corresponding functions in the Data Controller is not getting called. Everything is working fine with client.

it('it should edit drive details', function (done) {
  var ids = { 'ids': [1, 2, 3]}
  var editMap = {class: "Drives"}
  try {
    server
      .put('/api/1/drives')
      .send({driveIds, editMap})
      .expect(200, done());
  } catch (err) {
    done(err);
  }
}

And the route is defined in config/routes.js:

'put /api/1/drives': {
  controller: 'DataController',
  action: 'editDrives'
}

I have checked after removing the promises and other settings as well.

Aucun commentaire:

Enregistrer un commentaire