Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe('static', function() {
- describe('method `getAll`', function() {
- ...
- beforeEach(function() {
- $httpBackend.whenPOST(url, getPanelsForCategory)
- .respond(mockPanelsForCategory);
- $httpBackend.whenPOST(url, getPanelDetails)
- .respond(mockPanel);
- });
- it('should work... Please...', function() {
- $httpBackend.expectPOST(url, getPanelsForCategory);
- Panel.getAll('category', 1).then(function(panels) {
- // Here everything falls down.
- });
- $httpBackend.flush();
- });
- });
- });
- Panel.get = function(id) {
- return API.getPanel(id).then(function(panel) {
- return new Panel(panel);
- });
- };
- Panel.getAll = function(id) {
- var handleResponse = function(data) {
- var promise = $q.all(
- data.map(function(panelRaw) {
- var panel = Panel.get(panelRaw.PANEL_ID);
- return panel;
- })
- );
- return promise;
- };
- return API.getPanelsForCategory(id).then(handleResponse);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement