Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. describe('static', function() {
  2. describe('method `getAll`', function() {
  3. ...
  4. beforeEach(function() {
  5. $httpBackend.whenPOST(url, getPanelsForCategory)
  6. .respond(mockPanelsForCategory);
  7. $httpBackend.whenPOST(url, getPanelDetails)
  8. .respond(mockPanel);
  9. });
  10.  
  11. it('should work... Please...', function() {
  12. $httpBackend.expectPOST(url, getPanelsForCategory);
  13.  
  14. Panel.getAll('category', 1).then(function(panels) {
  15. // Here everything falls down.
  16. });
  17.  
  18. $httpBackend.flush();
  19. });
  20. });
  21. });
  22.  
  23. Panel.get = function(id) {
  24. return API.getPanel(id).then(function(panel) {
  25. return new Panel(panel);
  26. });
  27. };
  28.  
  29. Panel.getAll = function(id) {
  30. var handleResponse = function(data) {
  31. var promise = $q.all(
  32. data.map(function(panelRaw) {
  33. var panel = Panel.get(panelRaw.PANEL_ID);
  34. return panel;
  35. })
  36. );
  37.  
  38. return promise;
  39. };
  40.  
  41. return API.getPanelsForCategory(id).then(handleResponse);
  42. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement