Advertisement
Guest User

Untitled

a guest
Jan 8th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. describe('Service: AuthFactory',function(){
  2.  
  3. beforeEach(function () {
  4. module('ui.router');
  5. module('users');
  6. });
  7.  
  8. var AuthFactory, httpBackend;
  9.  
  10. beforeEach(function($httpBackend, _AuthFactory_) {
  11. httpBackend = $httpBackend;
  12. AuthFactory = _AuthFactory_;
  13. });
  14.  
  15. it('should return POST', function(done) {
  16. AuthFactory.signIn({inputType: {user: "admin"}, credInput: {password: "pass123"}})
  17. .then(
  18. function(result) {
  19. console.log('======== SUCCESS ========');
  20. console.log(result);
  21. },
  22. function(err) {
  23. console.log('======== ERROR ========');
  24. console.log(err);
  25. })
  26. .then(function(){
  27. console.log('HTTP call finished.');
  28. expect(1).toBe(1);
  29. }).finally(done);
  30. }, 20000);
  31.  
  32. });
  33.  
  34. angular.module('users').factory('AuthFactory', ['$http', function($http) {
  35.  
  36. var AuthFactory = {};
  37.  
  38. AuthFactory.signIn = function(data) {
  39. return $http.post('http://localhost:3000/api/AuthFactoryServ/signIn', data);
  40. };
  41.  
  42. AuthFactory.signOut = function(data) {
  43. return $http.post('http://localhost:3000/api/AuthFactoryServ/signOut', data);
  44. };
  45.  
  46. return AuthFactory;
  47.  
  48. }]);
  49.  
  50. PhantomJS 1.9.8 (Windows 7 0.0.0) Service: Authentication should return POST F
  51. AILED
  52. Error: Timeout - Async callback was not invoked within timeout specifi
  53. ed by jasmine.DEFAULT_TIMEOUT_INTERVAL.
  54. TypeError: 'undefined' is not an object (evaluating 'AuthFactory.signIn')
  55. at C:/maink/client/tests/signInSpec.js:1
  56.  
  57. it('should return POST', function(done) {
  58. // dont worry about calls to assets
  59. httpBackend.when ('POST','http://localhost:3000/api/AuthFactoryServ/signIn')
  60. .respond (200, {});
  61.  
  62. httpBackend.flush(); // to return the response
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement