replaced returnValur for returnThis
gitea/salix/2131_jest_spyOn This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2020-02-27 07:19:42 +01:00
parent 0fd012930e
commit 6c668131a4
8 changed files with 11 additions and 11 deletions

View File

@ -28,7 +28,7 @@ describe('Component vnWatcher', () => {
it('should call fetchData() if controllers get and url properties are defined', () => {
controller.get = () => {};
controller.url = 'test.com';
jest.spyOn(controller, 'fetchData').mockReturnValue('ok!');
jest.spyOn(controller, 'fetchData').mockReturnThis();
controller.$onInit();
expect(controller.fetchData).toHaveBeenCalledWith();

View File

@ -45,7 +45,7 @@ describe('Client', () => {
describe('company setter/getter', () => {
it('should return the company and then call getData()', () => {
jest.spyOn(controller, 'getData').mockReturnValue('ok!');
jest.spyOn(controller, 'getData').mockReturnThis();
controller.companyId = 442;
expect(controller._companyId).toEqual(442);
@ -115,7 +115,7 @@ describe('Client', () => {
});
it('should set the balances data and then call the getBalances() method', () => {
jest.spyOn(controller, 'getBalances').mockReturnValue('ok!');
jest.spyOn(controller, 'getBalances').mockReturnThis();
controller.balances = [{
id: 1,
debit: 1000,

View File

@ -72,7 +72,7 @@ describe('Client', () => {
describe('returnDialog()', () => {
it('should call the returnDialog method and perform a PATCH query, then call _getClassifications method', () => {
jest.spyOn(controller, '_getClassifications').mockReturnValue('ok!');
jest.spyOn(controller, '_getClassifications').mockReturnThis();
controller.classificationId = 1;
$httpBackend.when('PATCH', `CreditClassifications/1`).respond(200);
$httpBackend.expect('PATCH', `CreditClassifications/1`);

View File

@ -17,7 +17,7 @@ describe('Client', () => {
it('should perform a GET query and then define the summary property', () => {
let res = {name: 'Superman', classifications: []};
jest.spyOn(controller, 'sumRisk').mockReturnValue('ok!');
jest.spyOn(controller, 'sumRisk').mockReturnThis();
$httpBackend.when('GET', `Clients/101/summary`).respond(200, res);
$httpBackend.expect('GET', `Clients/101/summary`);

View File

@ -159,7 +159,7 @@ describe('Route', () => {
describe('removeTicketFromRoute()', () => {
it('should perform a patch query then call showSuccess and updateVolume methods', () => {
jest.spyOn(controller, 'updateVolume').mockReturnValue('ok!');
jest.spyOn(controller, 'updateVolume').mockReturnThis();
jest.spyOn(controller.vnApp, 'showSuccess');
let ticketId = 1;
controller.selectedTicket = ticketId;

View File

@ -119,7 +119,7 @@ describe('Ticket Component vnTicketDescriptor', () => {
describe('makeInvoice()', () => {
it('should make a query and call $state.reload() method if the response is accept', () => {
jest.spyOn(controller.$state, 'reload').mockReturnValue('ok!');
jest.spyOn(controller.$state, 'reload').mockReturnThis();
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.when('POST', 'Tickets/2/makeInvoice').respond();

View File

@ -110,7 +110,7 @@ describe('Ticket', () => {
let filter = {where: {code: 'OK'}, fields: ['id']};
filter = encodeURIComponent(JSON.stringify(filter));
let res = [{id: 3}];
jest.spyOn(controller, 'onStateChange').mockReturnValue('ok!');
jest.spyOn(controller, 'onStateChange').mockReturnThis();
$httpBackend.whenGET(`States?filter=${filter}`).respond(res);
$httpBackend.expectGET(`Tickets/1/subtotal`).respond(200, 227.5);

View File

@ -20,7 +20,7 @@ describe('Component vnWorkerTimeControl', () => {
describe('date() setter', () => {
it(`should set the weekDays, the date in the controller and call fetchHours`, () => {
let today = new Date();
jest.spyOn(controller, 'fetchHours').mockReturnValue('ok!');
jest.spyOn(controller, 'fetchHours').mockReturnThis();
controller.date = today;
@ -35,7 +35,7 @@ describe('Component vnWorkerTimeControl', () => {
describe('hours() setter', () => {
it(`should set hours data at it's corresponding week day`, () => {
let today = new Date();
jest.spyOn(controller, 'fetchHours').mockReturnValue('ok!');
jest.spyOn(controller, 'fetchHours').mockReturnThis();
controller.date = today;
@ -66,7 +66,7 @@ describe('Component vnWorkerTimeControl', () => {
describe('getWorkedHours() ', () => {
it('should set the weekdays expected and worked hours plus the total worked hours', () => {
let today = new Date();
jest.spyOn(controller, 'fetchHours').mockReturnValue('ok!');
jest.spyOn(controller, 'fetchHours').mockReturnThis();
controller.date = today;