app.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. process.env.NODE_ENV = 'test';
  2. const config = require('../config');
  3. let server = require('../app');
  4. let chai = require('chai');
  5. let chaiHttp = require('chai-http');
  6. const {
  7. expect
  8. } = require('chai');
  9. let should = chai.should();
  10. chai.use(chaiHttp);
  11. describe('App.js', () => {
  12. /*
  13. * Test the /GET route
  14. */
  15. describe('test the APP routes', () => {
  16. it('test /voice/ : we are looking for a 200 status', (done) => {
  17. chai.request(server)
  18. .post('/voice/' + config.apipassword)
  19. .end((err, res) => {
  20. res.should.have.status(200);
  21. res.should.to.be.json;
  22. res.body.should.have.property('error');
  23. done();
  24. });
  25. });
  26. it('test /get/ : we are looking for a 200 status', (done) => {
  27. chai.request(server)
  28. .post('/get')
  29. .set('content-type', 'application/x-www-form-urlencoded')
  30. .send({
  31. password: config.apipassword
  32. })
  33. .end((err, res) => {
  34. res.should.have.status(200);
  35. res.should.to.be.json;
  36. res.body.should.have.property('error');
  37. done();
  38. });
  39. });
  40. it('test /sms/ : we are looking for a 200 status', (done) => {
  41. chai.request(server)
  42. .post('/sms')
  43. .set('content-type', 'application/x-www-form-urlencoded')
  44. .send({
  45. password: config.apipassword
  46. })
  47. .end((err, res) => {
  48. res.should.have.status(200);
  49. res.should.to.be.json;
  50. res.body.should.have.property('error');
  51. done();
  52. });
  53. });
  54. it('test /status/ : we are looking for a 200 status', (done) => {
  55. chai.request(server)
  56. .post('/status/' + config.apipassword)
  57. .end((err, res) => {
  58. res.should.have.status(200);
  59. res.should.to.be.json;
  60. res.body.should.have.property('error');
  61. done();
  62. });
  63. });
  64. it('test /stream/default : we are looking for a 200 status', (done) => {
  65. chai.request(server)
  66. .get('/stream/fakeservice')
  67. .end((err, res) => {
  68. res.should.have.status(200);
  69. res.should.to.be.json;
  70. res.body.should.have.property('error');
  71. done();
  72. });
  73. });
  74. it('test /call/ : we are looking for a 200 status', (done) => {
  75. chai.request(server)
  76. .post('/call')
  77. .set('content-type', 'application/x-www-form-urlencoded')
  78. .send({
  79. password: config.apipassword
  80. })
  81. .end((err, res) => {
  82. res.should.have.status(200);
  83. res.should.to.be.json;
  84. res.body.should.have.property('error');
  85. done();
  86. });
  87. });
  88. });
  89. });