Skip to content

Commit

Permalink
Jest: toBeCalledWith is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
qmonmert committed May 29, 2024
1 parent d081e43 commit 7ec2fba
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('<%= entityAngularName %> Management Detail Component', () => {
comp.byteSize(fakeBase64);

// THEN
expect(dataUtils.byteSize).toBeCalledWith(fakeBase64);
expect(dataUtils.byteSize).toHaveBeenCalledWith(fakeBase64);
});
});

Expand All @@ -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);
});
});
<%_ } _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %> });
});

Expand Down Expand Up @@ -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']);
});
Expand Down
54 changes: 27 additions & 27 deletions generators/base-application/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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' });
Expand Down Expand Up @@ -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);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 7ec2fba

Please sign in to comment.