Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. Error: Unsatisfied requests: POST http://localhost:5000/google-form
  2. at Function.$httpBackend.verifyNoOutstandingExpectation
  3. (.../angular-mocks/angular-mocks.js:1474:13)
  4.  
  5. /* global $ */
  6. 'use strict';
  7. angular.module('myApp')
  8. .controller('QuickMessageCtrl', ['$scope', function ($scope) {
  9. $scope.quickMessageButtonText = 'Send';
  10. $scope.quickMessage = {
  11. name: '',
  12. email: '',
  13. content: '',
  14. };
  15.  
  16. function setSubmittingIndicators() {
  17. $scope.quickMessageButtonText = '';
  18. $scope.submitting = true;
  19. }
  20.  
  21. $scope.postQuickMessageToGoogle = _.throttle(function() {
  22. setSubmittingIndicators();
  23. $.ajax({
  24. url: 'https://docs.google.com/forms/d/MyFormKey/formResponse',
  25. data: {
  26. 'entry.3' : $scope.quickMessage.name,
  27. 'entry.1' : $scope.quickMessage.email,
  28. 'entry.0' : $scope.quickMessage.content
  29. },
  30. type: 'POST',
  31. dataType: 'jsonp',
  32. statusCode: {
  33. 200: function (){
  34. //show succes message;
  35. }
  36. }
  37. });
  38. }, 500);
  39. }]);
  40.  
  41. 'use strict';
  42.  
  43. describe('Controller: QuickMessageCtrl', function() {
  44. var $httpBackend, $rootScope, $controller, scope, apiUrl;
  45.  
  46. beforeEach(module('myApp'));
  47.  
  48. beforeEach(inject(function($injector) {
  49. $httpBackend = $injector.get('$httpBackend');
  50. apiUrl = $injector.get('apiUrl');
  51. $httpBackend.expect(
  52. 'POST',
  53. apiUrl + 'google-form',
  54. {'name': 'test', 'email': 'test@test.com', 'content': 'this is content'}
  55. ).respond(200);
  56.  
  57. $rootScope = $injector.get('$rootScope');
  58. scope = $rootScope.$new();
  59. $controller = $injector.get('$controller');
  60. $controller('QuickMessageCtrl', { $scope: scope });
  61. }));
  62.  
  63. afterEach(function() {
  64. $httpBackend.verifyNoOutstandingExpectation();
  65. $httpBackend.verifyNoOutstandingRequest();
  66. });
  67.  
  68. describe('Successful form submit', function() {
  69. beforeEach(function() {
  70. scope.quickMessageForm = { $valid: true };
  71. scope.quickMessage.email = 'test@test.com';
  72. scope.quickMessage.name = 'test';
  73. scope.quickMessage.content = 'this is test';
  74. scope.postQuickMessageToGoogle();
  75. });
  76.  
  77. it('should set submitting indicators on submit', function() {
  78. expect(scope.quickMessageButtonText).toBe('');
  79. });
  80.  
  81. });
  82. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement