Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. describe('GET: /user/login', () => {
  2.  
  3. it('Should return success GET status', () => {
  4. return $http.post('/user/login', {
  5. email: 'adith@gmail.com',
  6. password: 'adith123'
  7. })
  8. .then(response => {
  9. response.status.should.equal(200);
  10. })
  11. });
  12.  
  13. it('Should return fail GET status, because email or password is incorrect', () => {
  14. return $http.post('/user/login', {
  15. email: 'adith@gmail.com',
  16. password: 'wR0n6_P4A55WoRd'
  17. })
  18. .catch(err => {
  19. let failAuthState = err.data;
  20. authState.should.have.property('message').and.to.be.a('string');
  21. })
  22.  
  23. });
  24.  
  25. it(`Should return true because have 'email:' property`, () => {
  26. return $http.post('/user/login', {
  27. email: 'adith@gmail.com',
  28. password: 'adith123'
  29. })
  30. .then(response => {
  31. let authState = response.data;
  32. authState.should.have.property('email').and.to.be.a('string');
  33. })
  34. })
  35.  
  36. it(`Should return true because have 'email:' property and have '@'`, () => {
  37. return $http.post('/user/login', {
  38. email: 'adith@gmail.com',
  39. password: 'adith123'
  40. })
  41. .then(response => {
  42. let authState = response.data;
  43. authState.should.have.property('email').and.have.string('@');
  44. })
  45. })
  46.  
  47. it(`Should return true because have 'providerData:' property`, () => {
  48. return $http.post('/user/login', {
  49. email: 'adith@gmail.com',
  50. password: 'adith123'
  51. })
  52. .then(response => {
  53. let authState = response.data;
  54. authState.should.have.property('providerData').and.to.be.an('array');
  55. })
  56. })
  57.  
  58. it(`Should return true because have 'providerData:' property and have certain length`, () => {
  59. return $http.post('/user/login', {
  60. email: 'adith@gmail.com',
  61. password: 'adith123'
  62. })
  63. .then(response => {
  64. let authState = response.data;
  65. authState.should.have.property('providerData').and.to.be.an('array').and.to.have.lengthOf(1);
  66. })
  67. })
  68.  
  69. it(`Should return true because have 'emailVerified:' property and valued false`, () => {
  70. return $http.post('/user/login', {
  71. email: 'adith@gmail.com',
  72. password: 'adith123'
  73. })
  74. .then(response => {
  75. let authState = response.data;
  76. authState.should.have.property('emailVerified').and.to.be.false;
  77. })
  78. })
  79.  
  80. it(`Should return true because have 'displayName:' property and valued null because app doesn't allow full name`, () => {
  81. return $http.post('/user/login', {
  82. email: 'adith@gmail.com',
  83. password: 'adith123'
  84. })
  85. .then(response => {
  86. let authState = response.data;
  87. authState.should.have.property('displayName').and.to.be.null;
  88. })
  89. })
  90.  
  91. it(`Should return true because have 'stsTokenManager:' property and is and object that contains importan objects`, () => {
  92. return $http.post('/user/login', {
  93. email: 'adith@gmail.com',
  94. password: 'adith123'
  95. })
  96. .then(response => {
  97. let authState = response.data;
  98. authState.should.have.property('stsTokenManager').and.to.be.an('object')
  99. })
  100. })
  101.  
  102. it(`Should return true because have 'apiKey: and accessToken:' property inside stsTokenManager object`, () => {
  103. return $http.post('/user/login', {
  104. email: 'adith@gmail.com',
  105. password: 'adith123'
  106. })
  107. .then(response => {
  108. let authState = response.data.stsTokenManager;
  109. authState.should.have.property('apiKey')
  110. authState.should.have.property('accessToken')
  111. })
  112. })
  113.  
  114. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement