users.endpoint.Test.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. "use strict";
  2. var testConfig = require('../config');
  3. var APIv1 = require('../../../src/server/include/endpoints').APIv1;
  4. var should = require("should");
  5. var server = require('supertest').agent(testConfig.host);
  6. describe('User Endpoint', function () {
  7. describe('when login with correct params', function () {
  8. it('should return 200', function (done) {
  9. var path = APIv1.Users.Base + APIv1.Users.Login + "?user_id=0de7295862dd11e69faffa163e8aee56&token=0PFWlKmLBN9YzhCfFWVgYA&client_id=H6FYbDejks6VjMmW3uH7V6&platform=0";
  10. server.get(path)
  11. .expect(200)
  12. .end(done);
  13. })
  14. });
  15. describe('when login without user_id', function () {
  16. it('should return 406', function (done) {
  17. var path = APIv1.Users.Base + APIv1.Users.Login + "?token=0PFWlKmLBN9YzhCfFWVgYA&client_id=H6FYbDejks6VjMmW3uH7V6&platform=0";
  18. server.get(path)
  19. .expect(406, done);
  20. });
  21. });
  22. describe('when login without client_id', function () {
  23. it('should return 406', function (done) {
  24. var path = APIv1.Users.Base + APIv1.Users.Login + "?user_id=0de7295862dd11e69faffa163e8aee56&token=0PFWlKmLBN9YzhCfFWVgYA&platform=0";
  25. server.get(path)
  26. .expect(406, done);
  27. });
  28. });
  29. describe('when login without token', function () {
  30. it('should return 406', function (done) {
  31. var path = APIv1.Users.Base + APIv1.Users.Login + "?user_id=0de7295862dd11e69faffa163e8aee56&token=0PFWlKmLBN9YzhCfFWVgYA&platform=0";
  32. server.get(path)
  33. .expect(406, done);
  34. });
  35. });
  36. describe('when login without platform', function () {
  37. it('should return 406', function (done) {
  38. var path = APIv1.Users.Base + APIv1.Users.Login + "?token=0PFWlKmLBN9YzhCfFWVgYA&client_id=H6FYbDejks6VjMmW3uH7V6";
  39. server.get(path)
  40. .expect(406, done);
  41. });
  42. });
  43. describe('when update user status', function () {
  44. it('should return 200', function (done) {
  45. var path = APIv1.Users.Base + "/0de7295862dd11e69faffa163e8aee56/status";
  46. server.post(path)
  47. .set('Content-Type', 'application/json')
  48. .set('X-HTTP-Method-Override', 'POST')
  49. .send({status: 1})
  50. .expect(200, done);
  51. });
  52. });
  53. describe('when user logout', function () {
  54. it('should return 200', function (done) {
  55. var path = APIv1.Users.Base + APIv1.Users.Logout + "?user_id=0de7295862dd11e69faffa163e8aee56";
  56. server.get(path)
  57. .expect(200, done);
  58. });
  59. });
  60. });