From 7ec2fba9db52de23c02d1ba92a79372557a71092 Mon Sep 17 00:00:00 2001 From: Quentin Date: Wed, 29 May 2024 23:05:53 +0200 Subject: [PATCH] Jest: toBeCalledWith is deprecated --- .../_entityFile_-detail.component.spec.ts.ejs | 4 +- ...yFile_-routing-resolve.service.spec.ts.ejs | 4 +- generators/base-application/generator.spec.ts | 54 +++++++++---------- .../admin/tracker/tracker.service.spec.ts.ejs | 2 +- .../shared/alert/alert.service.spec.ts.ejs | 16 +++--- .../data/data-utils.service.spec.ts.ejs | 2 +- 6 files changed, 41 insertions(+), 41 deletions(-) diff --git a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.spec.ts.ejs b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.spec.ts.ejs index 58c17417955..fc4265f6088 100644 --- a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.spec.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.spec.ts.ejs @@ -96,7 +96,7 @@ describe('<%= entityAngularName %> Management Detail Component', () => { comp.byteSize(fakeBase64); // THEN - expect(dataUtils.byteSize).toBeCalledWith(fakeBase64); + expect(dataUtils.byteSize).toHaveBeenCalledWith(fakeBase64); }); }); @@ -116,7 +116,7 @@ describe('<%= entityAngularName %> Management Detail Component', () => { comp.openFile(fakeBase64, fakeContentType); // THEN - expect(dataUtils.openFile).toBeCalledWith(fakeBase64, fakeContentType); + expect(dataUtils.openFile).toHaveBeenCalledWith(fakeBase64, fakeContentType); }); }); <%_ } _%> diff --git a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/route/_entityFile_-routing-resolve.service.spec.ts.ejs b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/route/_entityFile_-routing-resolve.service.spec.ts.ejs index 6134e27116a..e9658bb6ce2 100644 --- a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/route/_entityFile_-routing-resolve.service.spec.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/route/_entityFile_-routing-resolve.service.spec.ts.ejs @@ -73,7 +73,7 @@ describe('<%= entityAngularName %> routing resolve service', () => { }); // THEN - expect(service.find).toBeCalledWith(<%- tsKeyId %>); + expect(service.find).toHaveBeenCalledWith(<%- tsKeyId %>); expect(result<%= entityAngularName %>).toEqual({ <%= primaryKey.name %>: <%- tsKeyId %> }); }); @@ -111,7 +111,7 @@ describe('<%= entityAngularName %> routing resolve service', () => { }); // THEN - expect(service.find).toBeCalledWith(<%- tsKeyId %>); + expect(service.find).toHaveBeenCalledWith(<%- tsKeyId %>); expect(result<%= entityAngularName %>).toEqual(undefined); expect(mockRouter.navigate).toHaveBeenCalledWith(['404']); }); diff --git a/generators/base-application/generator.spec.ts b/generators/base-application/generator.spec.ts index 545fc27285f..2b566ff7f97 100644 --- a/generators/base-application/generator.spec.ts +++ b/generators/base-application/generator.spec.ts @@ -233,12 +233,12 @@ describe(`generator - ${generator}`, () => { entities: [expect.any(Object), expect.any(Object), expect.any(Object), expect.any(Object), expect.any(Object), expect.any(Object)], }; - expect(initializing).toBeCalledWith(controlArg); - expect(prompting).toBeCalledWith(controlArg); - expect(configuring).toBeCalledWith(controlArg); - expect(composing).toBeCalledWith(controlArg); - expect(loading).toBeCalledWith(applicationDefaultsArg); - expect(postPreparing).toBeCalledWith(applicationSourceArg); + expect(initializing).toHaveBeenCalledWith(controlArg); + expect(prompting).toHaveBeenCalledWith(controlArg); + expect(configuring).toHaveBeenCalledWith(controlArg); + expect(composing).toHaveBeenCalledWith(controlArg); + expect(loading).toHaveBeenCalledWith(applicationDefaultsArg); + expect(postPreparing).toHaveBeenCalledWith(applicationSourceArg); expect(configuringEachEntity).toBeCalledTimes(3); expect(configuringEachEntity).toHaveBeenNthCalledWith(1, { ...entityConfiguringArg, entityName: 'One' }); @@ -279,16 +279,16 @@ describe(`generator - ${generator}`, () => { expect(postPreparingEachEntity).toHaveBeenNthCalledWith(5, { ...entityArg, entityName: 'Two' }); expect(postPreparingEachEntity).toHaveBeenNthCalledWith(6, { ...entityArg, entityName: 'Three' }); - expect(defaultTask).toBeCalledWith(entitiesArg); - expect(writingEntities).toBeCalledWith(entitiesArg); - expect(postWritingEntities).toBeCalledWith({ ...entitiesArg, source: expect.any(Object) }); + expect(defaultTask).toHaveBeenCalledWith(entitiesArg); + expect(writingEntities).toHaveBeenCalledWith(entitiesArg); + expect(postWritingEntities).toHaveBeenCalledWith({ ...entitiesArg, source: expect.any(Object) }); - expect(writing).toBeCalledWith(applicationArg); - expect(install).toBeCalledWith(applicationArg); - expect(end).toBeCalledWith(applicationArg); + expect(writing).toHaveBeenCalledWith(applicationArg); + expect(install).toHaveBeenCalledWith(applicationArg); + expect(end).toHaveBeenCalledWith(applicationArg); - expect(preparing).toBeCalledWith({ ...applicationSourceArg, ...applicationDefaultsArg }); - expect(postWriting).toBeCalledWith(applicationSourceArg); + expect(preparing).toHaveBeenCalledWith({ ...applicationSourceArg, ...applicationDefaultsArg }); + expect(postWriting).toHaveBeenCalledWith(applicationSourceArg); }); }); @@ -485,11 +485,11 @@ describe(`generator - ${generator}`, () => { source: expect.any(Object), }; - expect(initializing).toBeCalledWith(controlArg); - expect(prompting).toBeCalledWith(controlArg); - expect(configuring).toBeCalledWith(controlArg); - expect(composing).toBeCalledWith(controlArg); - expect(loading).toBeCalledWith(applicationDefaultsArg); + expect(initializing).toHaveBeenCalledWith(controlArg); + expect(prompting).toHaveBeenCalledWith(controlArg); + expect(configuring).toHaveBeenCalledWith(controlArg); + expect(composing).toHaveBeenCalledWith(controlArg); + expect(loading).toHaveBeenCalledWith(applicationDefaultsArg); expect(configuringEachEntity).toBeCalledTimes(3); expect(configuringEachEntity).toHaveBeenNthCalledWith(1, { ...entityConfiguringArg, entityName: 'One' }); @@ -530,17 +530,17 @@ describe(`generator - ${generator}`, () => { expect(postPreparingEachEntity).toHaveBeenNthCalledWith(5, { ...entityArg, entityName: 'Two' }); expect(postPreparingEachEntity).toHaveBeenNthCalledWith(6, { ...entityArg, entityName: 'Three' }); - expect(defaultTask).toBeCalledWith(entitiesArg); + expect(defaultTask).toHaveBeenCalledWith(entitiesArg); - expect(writingEntities).toBeCalledWith(writingEntitiesArg); - expect(postWritingEntities).toBeCalledWith(postWritingEntitiesArg); + expect(writingEntities).toHaveBeenCalledWith(writingEntitiesArg); + expect(postWritingEntities).toHaveBeenCalledWith(postWritingEntitiesArg); - expect(writing).toBeCalledWith(applicationArg); - expect(install).toBeCalledWith(applicationArg); - expect(end).toBeCalledWith(applicationArg); + expect(writing).toHaveBeenCalledWith(applicationArg); + expect(install).toHaveBeenCalledWith(applicationArg); + expect(end).toHaveBeenCalledWith(applicationArg); - expect(preparing).toBeCalledWith({ ...applicationSourceArg, ...applicationDefaultsArg }); - expect(postWriting).toBeCalledWith(applicationSourceArg); + expect(preparing).toHaveBeenCalledWith({ ...applicationSourceArg, ...applicationDefaultsArg }); + expect(postWriting).toHaveBeenCalledWith(applicationSourceArg); }); }); }); diff --git a/generators/vue/templates/src/main/webapp/app/admin/tracker/tracker.service.spec.ts.ejs b/generators/vue/templates/src/main/webapp/app/admin/tracker/tracker.service.spec.ts.ejs index e5959a4a89f..2a597623f3a 100644 --- a/generators/vue/templates/src/main/webapp/app/admin/tracker/tracker.service.spec.ts.ejs +++ b/generators/vue/templates/src/main/webapp/app/admin/tracker/tracker.service.spec.ts.ejs @@ -91,7 +91,7 @@ describe('Tracker Service', () => { // THEN expect(mockStomp.publish).toBeCalledTimes(1); - expect(mockStomp.publish).toBeCalledWith({ destination: '/topic/activity', body: JSON.stringify({ page: '/admin' }) }); + expect(mockStomp.publish).toHaveBeenCalledWith({ destination: '/topic/activity', body: JSON.stringify({ page: '/admin' }) }); }); it('Should disconnect on logout', async () => { diff --git a/generators/vue/templates/src/main/webapp/app/shared/alert/alert.service.spec.ts.ejs b/generators/vue/templates/src/main/webapp/app/shared/alert/alert.service.spec.ts.ejs index e61a1261570..60a81a1c539 100644 --- a/generators/vue/templates/src/main/webapp/app/shared/alert/alert.service.spec.ts.ejs +++ b/generators/vue/templates/src/main/webapp/app/shared/alert/alert.service.spec.ts.ejs @@ -31,7 +31,7 @@ describe('Alert Service test suite', () => { // THEN expect(toastStub).toBeCalledTimes(1); - expect(toastStub).toBeCalledWith(message, { + expect(toastStub).toHaveBeenCalledWith(message, { toaster: 'b-toaster-top-center', title: 'Error', variant: 'danger', @@ -62,7 +62,7 @@ describe('Alert Service test suite', () => { expect(translationStub).toHaveBeenCalledWith(translationKey); <%_ } _%> expect(toastStub).toBeCalledTimes(1); - expect(toastStub).toBeCalledWith(message, { + expect(toastStub).toHaveBeenCalledWith(message, { toaster: 'b-toaster-top-center', title: 'Error', variant: 'danger', @@ -102,10 +102,10 @@ describe('Alert Service test suite', () => { // THEN <%_ if (enableTranslation) { _%> expect(translationStub).toBeCalledTimes(2); - expect(translationStub).toBeCalledWith(translationKey, { entityName: 'DummyEntity' }); - expect(translationStub).toBeCalledWith('global.menu.entities.dummyEntity'); + expect(translationStub).toHaveBeenCalledWith(translationKey, { entityName: 'DummyEntity' }); + expect(translationStub).toHaveBeenCalledWith('global.menu.entities.dummyEntity'); <%_ } _%> - expect(toastStub).toBeCalledWith(message, { + expect(toastStub).toHaveBeenCalledWith(message, { toaster: 'b-toaster-top-center', title: 'Error', variant: 'danger', @@ -144,7 +144,7 @@ describe('Alert Service test suite', () => { expect(translationStub).toHaveBeenCalledWith(message); <%_ } _%> expect(toastStub).toBeCalledTimes(1); - expect(toastStub).toBeCalledWith(message, { + expect(toastStub).toHaveBeenCalledWith(message, { toaster: 'b-toaster-top-center', title: 'Error', variant: 'danger', @@ -176,7 +176,7 @@ describe('Alert Service test suite', () => { expect(translationStub).toHaveBeenCalledWith(translationKey); <%_ } _%> expect(toastStub).toBeCalledTimes(1); - expect(toastStub).toBeCalledWith(message, { + expect(toastStub).toHaveBeenCalledWith(message, { toaster: 'b-toaster-top-center', title: 'Error', variant: 'danger', @@ -208,7 +208,7 @@ describe('Alert Service test suite', () => { expect(translationStub).toHaveBeenCalledWith(message); <%_ } _%> expect(toastStub).toBeCalledTimes(1); - expect(toastStub).toBeCalledWith(message, { + expect(toastStub).toHaveBeenCalledWith(message, { toaster: 'b-toaster-top-center', title: 'Error', variant: 'danger', diff --git a/generators/vue/templates/src/main/webapp/app/shared/data/data-utils.service.spec.ts.ejs b/generators/vue/templates/src/main/webapp/app/shared/data/data-utils.service.spec.ts.ejs index f0be8a3d7d8..7a7c2fdb4d1 100644 --- a/generators/vue/templates/src/main/webapp/app/shared/data/data-utils.service.spec.ts.ejs +++ b/generators/vue/templates/src/main/webapp/app/shared/data/data-utils.service.spec.ts.ejs @@ -43,7 +43,7 @@ describe('Formatter i18n', () => { dataUtilsService.openFile('text', 'data'); - expect(window.open).toBeCalledWith(objectURL); + expect(window.open).toHaveBeenCalledWith(objectURL); }); it('should check text ends with suffix', () => {