Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 7th, 2013  |  syntax: None  |  size: 6.58 KB  |  views: 128  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Error: Argument 'fn' is not a function, got string
  2.   at Error (<anonymous>)
  3.   at $a (path/app/lib/angular.js:16:453)
  4.   at qa (path/app/lib/angular.js:17:56)
  5.   at Cb (path/app/lib/angular.js:24:458)
  6.   at Object.d [as invoke] (path/app/lib/angular.js:27:66)
  7.   at path/app/lib/angular.js:26:194
  8.   at Array.forEach (native)
  9.   at m (path/app/lib/angular.js:6:192)
  10.   at e (path/app/lib/angular.js:25:298)
  11.   at Object.sb [as injector] (path/app/lib/angular.js:29:360)
  12. TypeError: Cannot read property 'zip' of undefined
  13.   at null.<anonymous> (path/test/unit/controllersSpec.js:26:19)
  14.        
  15. 'use strict';
  16.  
  17. /* jasmine specs for controllers go here */
  18.  
  19. describe('influences controllers', function() {
  20.   beforeEach(module('influences.controllers', ['ui.bootstrap', 'influences.services']));
  21.  
  22.   describe('IndividualCtrl', function(){
  23.  
  24.     var scope, ctrl, service, $httpBackend;
  25.  
  26.     beforeEach(inject(function(_$httpBackend_, $rootScope, $controller, Api_sunlight_get) {
  27.       console.log('*** IN INJECT!!***: ', Api_sunlight_get);
  28.       $httpBackend = _$httpBackend_;
  29.       // ignore for now... this is an example of how I might implement this later
  30.       // $httpBackend.expectGET('data/products.json').
  31.       //     respond([{name: 'Celeri'}, {name: 'Panais'}]);
  32.  
  33.       scope = $rootScope.$new();
  34.       service = Api_sunlight_get;
  35.       ctrl = $controller('IndividualCtrl', {$scope: scope, Api_sunlight_get: service
  36.       });
  37.     }));
  38.  
  39.     it('should create "products" model with 2 products fetched from xhr', function() {
  40.       console.log('*** IN TEST!!***: ', scope);
  41.       expect(scope.zip).toEqual(12345);
  42.     });
  43.   });
  44. });
  45.        
  46. angular
  47.   .module('influences.controllers', ['ui.bootstrap', 'influences.services'])
  48.   .controller('IndividualCtrl', ['$scope', 'Api_sunlight_get', ($scope, Api_sunlight_get)->
  49.     # set default variables
  50.     $scope.zip = $scope.zip or 94102  # set default zip if one is not chosen
  51.  
  52.     # Define Methods
  53.     $scope.get_rep_data_by_zip = ()->
  54.       $scope.reps =  Api_sunlight_get "legislators/locate?zip=#{$scope.zip}" $scope.update_rep_data_by_zip
  55.  
  56.     $scope.update_rep_data_by_zip = ()->
  57.       $scope.selected_rep = $scope.reps  # sets default selection for reps buttons
  58.       for rep in $scope.reps
  59.         rep.fullname = "" + rep.title + " " + rep.first_name + " " + rep.last_name
  60.  
  61.     # watchers
  62.     $scope.$watch('zip', $scope.get_rep_data_by_zip)
  63.  
  64.     # initial run
  65.     $scope.get_rep_data_by_zip()
  66.        
  67. angular
  68.   .module('influences.services', [])
  69.   .factory 'Api_sunlight_get', ['$http', ($http)->
  70.     return (path, callback)->
  71.       $http
  72.         url: "http://congress.api.sunlightfoundation.com/#{path}&apikey=xxxx"
  73.         method: "GET"
  74.       .success (data, status, headers, config)->
  75.         callback data.results
  76.       .error (data, status, headers, config)->
  77.         console.log("Error pulling #{path} from Sunlight API!")
  78.   ]
  79.        
  80. 'use strict';
  81.  
  82. /* jasmine specs for controllers go here */
  83.  
  84. describe('influences controllers', function() {
  85.   // Change is here. Notice how the dependencies of the influences.controllers
  86.   // module are specified separately in another beforeEach directive
  87.   beforeEach(module('influences.controllers'));
  88.   beforeEach(function() {
  89.     module('ui.bootstrap');
  90.     module('influences.services');
  91.   });
  92.  
  93.   describe('IndividualCtrl', function(){
  94.  
  95.     var scope, ctrl, service, $httpBackend;
  96.  
  97.     beforeEach(inject(function(_$httpBackend_, $rootScope, $controller, Api_sunlight_get) {
  98.       console.log('*** IN INJECT!!***: ', Api_sunlight_get);
  99.       $httpBackend = _$httpBackend_;
  100.       // ignore for now... this is an example of how I might implement this later
  101.       // $httpBackend.expectGET('data/products.json').
  102.       //     respond([{name: 'Celeri'}, {name: 'Panais'}]);
  103.  
  104.       scope = $rootScope.$new();
  105.       service = Api_sunlight_get;
  106.       ctrl = $controller('IndividualCtrl', {$scope: scope, Api_sunlight_get: service
  107.       });
  108.     }));
  109.  
  110.     it('should create "products" model with 2 products fetched from xhr', function() {
  111.       console.log('*** IN TEST!!***: ', scope);
  112.       expect(scope.zip).toEqual(12345);
  113.     });
  114.   });
  115. });
  116.        
  117. karma start karma.test.conf.js
  118.        
  119. angular.module('influences.controllers', ['influences.services'])
  120.     .controller('IndividualCtrl', [
  121.         '$scope',
  122.         'Api_sunlight_get',
  123.         function($scope, Api_sunlight_get) {
  124.             $scope.zip = $scope.zip || 12345;
  125.         }
  126.     ])
  127.        
  128. angular.module('influences.services', [])
  129.     .factory('Api_sunlight_get', [
  130.         '$http',
  131.         function($http) {
  132.             console.log('Api_sunlight_get factory called');
  133.         }
  134.     ])
  135.        
  136. describe('influences controllers', function() {
  137.     beforeEach(module('influences.controllers'));
  138.     beforeEach(function() {
  139.         module('influences.services');
  140.     });
  141.     describe('IndividualCtrl', function() {
  142.         var scope
  143.           , ctrl
  144.           , service
  145.           , $httpBackend;
  146.         beforeEach(inject(function(_$httpBackend_, $rootScope, $controller, Api_sunlight_get) {
  147.             console.log('*** IN INJECT!! ***');
  148.             $httpBackend = _$httpBackend_;
  149.             scope = $rootScope.$new();
  150.             service = Api_sunlight_get;
  151.             ctrl = $controller('IndividualCtrl', {
  152.                 $scope: scope,
  153.                 Api_sunlight_get: service
  154.             });
  155.         }));
  156.  
  157.         it('should set the correct zip value', function() {
  158.             expect(scope.zip).toBe(12345);
  159.         });
  160.     });
  161. });
  162.        
  163. // Karma configuration
  164. // Generated on Tue Jul 02 2013 11:23:33 GMT+0800 (SGT)
  165.  
  166.  
  167. // base path, that will be used to resolve files and exclude
  168. basePath = './';
  169.  
  170.  
  171. // list of files / patterns to load in the browser
  172. files = [
  173.   JASMINE,
  174.   JASMINE_ADAPTER,
  175.   'angular.min.js',
  176.   'angular-mocks.js',
  177.   'service.js',
  178.   'ctrl.js',
  179.   'test.spec.js'
  180. ];
  181.  
  182.  
  183. // list of files to exclude
  184. exclude = [
  185. ];
  186.  
  187.  
  188. // test results reporter to use
  189. // possible values: 'dots', 'progress', 'junit'
  190. reporters = ['progress'];
  191.  
  192. hostname = '127.0.0.1';
  193.  
  194. // web server port
  195. port = 9876;
  196.  
  197.  
  198. // cli runner port
  199. runnerPort = 9100;
  200.  
  201.  
  202. // enable / disable colors in the output (reporters and logs)
  203. colors = true;
  204.  
  205.  
  206. // level of logging
  207. // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
  208. logLevel = LOG_INFO;
  209.  
  210.  
  211. // enable / disable watching file and executing tests whenever any file changes
  212. autoWatch = true;
  213.  
  214.  
  215. // Start these browsers, currently available:
  216. // - Chrome
  217. // - ChromeCanary
  218. // - Firefox
  219. // - Opera
  220. // - Safari (only Mac)
  221. // - PhantomJS
  222. // - IE (only Windows)
  223. browsers = ['PhantomJS'];
  224.  
  225.  
  226. // If browser does not capture in given timeout [ms], kill it
  227. captureTimeout = 60000;
  228.  
  229.  
  230. // Continuous Integration mode
  231. // if true, it capture browsers, run tests and exit
  232. singleRun = true;