text: 'use strict';
  
  /* jasmine specs for controllers go here */
  
  describe('services', function(){
    beforeEach(module('payment.module'));
    
    describe('Payment', function(){
  	var $httpBackend, Payment, restURL;
  	  
      beforeEach(inject(function($injector) {
      	$httpBackend = $injector.get('$httpBackend');
      	Payment = $injector.get('Payment');
          restURL = $injector.get('restURL');
      }));
  
      afterEach(function() {
      	$httpBackend.verifyNoOutstandingExpectation();
      	$httpBackend.verifyNoOutstandingRequest();
      });
      
  	it('getAllAsListItems', function() {
  		$httpBackend.when('GET', restURL+'/items/payment').respond("test");
      	Payment.getAllAsListItems().then(function(response) {
          	expect(response.status).toBe(200);
      		expect(response.data).toBe("test");
      	});
      	$httpBackend.flush();
  	});
  
      it('getAll', function() {
      	$httpBackend.when('GET', restURL+'/payment').respond("test");
      	Payment.getAll().then(function(response) {
          	expect(response.status).toBe(200);
      		expect(response.data).toBe("test");
      	});
      	$httpBackend.flush();
      });
      
      it('get', function() {
      	$httpBackend.when('GET', restURL+'/payment/1').respond("test");
      	Payment.get('1').then(function(response) {
          	expect(response.status).toBe(200);
      		expect(response.data).toBe("test");
      	});
      	$httpBackend.flush();
      });
      
      it('create throws exception : id not defined', function() {
      	try{
      		Payment.create({uid:null,name:'payment'});
      		$httpBackend.flush();
      	} catch(errors) {
      		expect(errors[0]).toBe('payment.id.not.defined');
      	}
      });
      
      it('create', function() {
      	$httpBackend.when('POST', restURL+'/payment').respond("test");
      	Payment.create({uid:'1',name:'payment'}).then(function(response) {
          	expect(response.status).toBe(200);
      		expect(response.data).toBe("test");
      	});
      	$httpBackend.flush();
      });
      
      it('update throws exception : id not defined', function() {
      	try{
      		Payment.update({uid:null,name:'payment'});
      		$httpBackend.flush();
      	} catch(errors) {
      		expect(errors[0]).toBe('payment.id.not.defined');
      	}
      });
      
      it('update', function() {
      	$httpBackend.when('PUT', restURL+'/payment/1').respond("test");
      	Payment.update({uid:'1',name:'payment'}).then(function(response) {
          	expect(response.status).toBe(200);
      		expect(response.data).toBe("test");
      	});
      	$httpBackend.flush();
      });
      
      it('delete', function() {
      	$httpBackend.when('DELETE', restURL+'/payment/1').respond("test");
      	Payment.delete('1').then(function(response) {
          	expect(response.status).toBe(200);
      		expect(response.data).toBe("test");
      	});
      	$httpBackend.flush();
      });
    });
  });