SHARE
TWEET

Untitled

a guest Jul 24th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. router.get("/url", function(req, res){
  2.   let options = { url: "http//some-api-en-point",
  3.     method: "GET",
  4.     resolveWithFullResponse: true
  5.   };
  6.   rp(options)
  7.   .then(function(response) {
  8.     if(response.statusCode == 200){
  9.       res.send({"data":response.data})
  10.     } else {
  11.       res.status(404).json("data":"NOT FOUND");
  12.     }
  13.   })
  14.   .catch(err => () => {
  15.     res.send(err);
  16.   })
  17. });
  18.      
  19. {
  20.   "id": "3f3e2b23e96c5250441d4be2340010ed",
  21.   "email": "let@example.com",
  22.   "status": "1"
  23. }
  24.      
  25. describe('TEST: /URL', () => {
  26.  
  27.   it('it should return Status 200', (done) => {
  28.     chai.request(app)
  29.       .get('/url')
  30.       .end((err, res) => {
  31.         sinon.stub(rp, 'Request').resolves({statusCode:200});
  32.         expect(res).to.have.status(200);
  33.         done();
  34.       });
  35.   });
  36. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top