Advertisement
Guest User

Untitled

a guest
Sep 15th, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. define(['angularMocks', 'services', 'controllers', 'app'],
  2.     function (angularMocks, services) {
  3.  
  4.         describe('SelectDesignCtrl', function () {
  5.             var scope,
  6.                 msgService; //we'll use this scope in our tests
  7.  
  8.             //mock Application to allow us to inject our own dependencies
  9.             beforeEach(module('editor.services'));
  10.             beforeEach(module('editor.controllers'));
  11.             beforeEach(module('editor'));
  12.  
  13.             //mock the controller for the same reason and include $rootScope and $controller
  14.             beforeEach(angular.mock.inject(
  15.                     function ($rootScope, $controller, $location, messageService) {
  16.  
  17.                         msgService = messageService;
  18.  
  19.                         spyOn(msgService, 'getDesigns');
  20.  
  21.                         //create an empty scope
  22.                         scope = $rootScope.$new();
  23.  
  24.                         //declare the controller and inject our empty scope
  25.                         $controller('SelectDesignCtrl', { $scope: scope }, $location, msgService);
  26.  
  27.                         spyOn(scope, 'selectDesign');
  28.                     }
  29.                 )
  30.             );
  31.             // tests start here
  32.             it('should stress generate new mails', function () {
  33.  
  34.                 var saveOptions = {
  35.                     generatePreview: false,
  36.                     forceSave: true
  37.                 };
  38.  
  39. //                for (var i = 0; i < 1000; i++) {
  40.                     // generar un mail
  41.  
  42.                     console.log('start creation');
  43.  
  44.                     msgService.save(saveOptions, function () {
  45.  
  46.                         msgService.setHeader({
  47.                             id: 0
  48.                         });
  49.  
  50.                         console.log('new mail end');
  51.                     });
  52. //                }
  53.             });
  54.  
  55.             it('should have get designs', function () {
  56.  
  57.                 expect(scope.selectDesign).not.toHaveBeenCalled();
  58.                 expect(msgService.getDesigns).toHaveBeenCalled();
  59.  
  60.                 expect(msgService.getDesigns.mostRecentCall.args[0])
  61.                     .toEqual({ pageIndex: 0, pageSize: 30, searchText: '', orderBy: 'Date Added' });
  62.             });
  63.         });
  64.  
  65.     }
  66. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement