Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe('Dado uma categoria', function () {
- var $controller = null;
- var $factory = null;
- var myScope = null;
- var $httpBackend= null;
- var myToastr = null;
- beforeEach(module('confsys'));
- beforeEach(inject(function (_$controller_,_CategoryFactory_,$rootScope) {
- myToastr = { success: function (message, title, options) { }, error: function (message, title, options) { } };
- myScope = $rootScope.$new();
- $factory = _CategoryFactory_;
- $controller = _$controller_('CreateCategoryCtrl', { $scope: myScope, CategoryFactory:$factory,toastr: myToastr});
- }));
- describe('Quando for criar uma categoria valída', function () {
- beforeEach(function () {
- spyOn($controller,'submit').and.callThrough();
- spyOn($factory,'create').and.callFake(function () {
- return{
- success:function (callBack) {
- callBack([{'id':'','name':'new category'}]);
- }
- }
- });
- spyOn(myToastr,'success').and.callThrough();
- spyOn(myToastr,'error').and.callThrough();
- });
- it('Então verifica se o metodo submit está implementado',function () {
- expect($controller.submit).not.toBe(undefined);
- });
- it('Então adiciona chamada á factory para salvar',function () {
- $controller.submit();
- expect($factory.create).toHaveBeenCalled();
- });
- it('Então notifica usuário que foi criado com sucesso',function () {
- $controller.submit();
- expect(myToastr.success).toHaveBeenCalled();
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement