From 902fc61028e08f2f6798f92daab56686b0f3bec2 Mon Sep 17 00:00:00 2001 From: xDivisionByZerox Date: Sun, 12 Jun 2022 13:48:02 +0200 Subject: [PATCH 1/5] chore(lorempicsum.avatar): deprecate --- src/modules/image/providers/lorempicsum.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/modules/image/providers/lorempicsum.ts b/src/modules/image/providers/lorempicsum.ts index 2586920513e..df8e70f9dd3 100644 --- a/src/modules/image/providers/lorempicsum.ts +++ b/src/modules/image/providers/lorempicsum.ts @@ -1,4 +1,5 @@ import type { Faker } from '../../..'; +import { deprecated } from '../../../internal/deprecated'; /** * Module to generate links to random images on `https://picsum.photos/`. @@ -73,12 +74,21 @@ export class LoremPicsum { /** * Returns a random avatar url. * + * @see faker.internet.avatar() + * * @example * faker.internet.avatar() * // 'https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/315.jpg' + * + * @deprecated */ - // TODO ST-DDT 2022-03-11: Deprecate this method as it is duplicate and has nothing to do with lorempicsum. avatar(): string { + deprecated({ + deprecated: 'faker.image.lorempicsum.avatar()', + proposed: 'this.faker.internet.avatar()', + since: 'v7.3.0', + until: 'v8.0.0', + }); return this.faker.internet.avatar(); } From 726100716d582c3d96476dd6e0b6b96d84582c6d Mon Sep 17 00:00:00 2001 From: xDivisionByZerox Date: Sun, 12 Jun 2022 13:51:19 +0200 Subject: [PATCH 2/5] test(image): lorempicsum avatar log message --- test/image.spec.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/image.spec.ts b/test/image.spec.ts index bbb99ffaaab..a6faca3df44 100644 --- a/test/image.spec.ts +++ b/test/image.spec.ts @@ -1,4 +1,4 @@ -import { describe, expect, it } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; import { faker } from '../src'; describe('image', () => { @@ -62,6 +62,21 @@ describe('image', () => { ) ).toBeTruthy(); }); + + it('should log a deprecation message', () => { + const consoleSpy = vi.spyOn(console, 'warn'); + + faker.image.lorempicsum.avatar(); + + expect(consoleSpy).toHaveBeenCalled(); + + const logMessage = consoleSpy.mock.calls[0][0]; + expect(logMessage).toContain('deprecated'); + expect(logMessage).toContain('faker.image.lorempicsum.avatar()'); + expect(logMessage).toContain('faker.internet.avatar()'); + expect(logMessage).toContain('v7.3.0'); + expect(logMessage).toContain('v8.0.0'); + }); }); describe('imageGrayscale()', () => { From 5f64a1187b257471afbed3752929708953145343 Mon Sep 17 00:00:00 2001 From: xDivisionByZerox Date: Sun, 12 Jun 2022 16:13:19 +0200 Subject: [PATCH 3/5] chore(lorempicsum.avatar): remove 'this' from deprecation message --- src/modules/image/providers/lorempicsum.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/image/providers/lorempicsum.ts b/src/modules/image/providers/lorempicsum.ts index df8e70f9dd3..ea4f89f91bf 100644 --- a/src/modules/image/providers/lorempicsum.ts +++ b/src/modules/image/providers/lorempicsum.ts @@ -85,7 +85,7 @@ export class LoremPicsum { avatar(): string { deprecated({ deprecated: 'faker.image.lorempicsum.avatar()', - proposed: 'this.faker.internet.avatar()', + proposed: 'faker.internet.avatar()', since: 'v7.3.0', until: 'v8.0.0', }); From 9eeddb98ef5cdfca1aad3777d990d95f1eae3e50 Mon Sep 17 00:00:00 2001 From: xDivisionByZerox Date: Tue, 14 Jun 2022 11:36:43 +0200 Subject: [PATCH 4/5] revert: test(image): lorempicsum avatar log message This reverts commit 726100716d582c3d96476dd6e0b6b96d84582c6d. --- test/image.spec.ts | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/test/image.spec.ts b/test/image.spec.ts index a6faca3df44..bbb99ffaaab 100644 --- a/test/image.spec.ts +++ b/test/image.spec.ts @@ -1,4 +1,4 @@ -import { describe, expect, it, vi } from 'vitest'; +import { describe, expect, it } from 'vitest'; import { faker } from '../src'; describe('image', () => { @@ -62,21 +62,6 @@ describe('image', () => { ) ).toBeTruthy(); }); - - it('should log a deprecation message', () => { - const consoleSpy = vi.spyOn(console, 'warn'); - - faker.image.lorempicsum.avatar(); - - expect(consoleSpy).toHaveBeenCalled(); - - const logMessage = consoleSpy.mock.calls[0][0]; - expect(logMessage).toContain('deprecated'); - expect(logMessage).toContain('faker.image.lorempicsum.avatar()'); - expect(logMessage).toContain('faker.internet.avatar()'); - expect(logMessage).toContain('v7.3.0'); - expect(logMessage).toContain('v8.0.0'); - }); }); describe('imageGrayscale()', () => { From 387986906fa2757501aa3c4c854c771252e49562 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Tue, 14 Jun 2022 21:40:28 +0200 Subject: [PATCH 5/5] chore: apply suggestions --- src/modules/image/providers/lorempicsum.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/image/providers/lorempicsum.ts b/src/modules/image/providers/lorempicsum.ts index ea4f89f91bf..77f5d0c6976 100644 --- a/src/modules/image/providers/lorempicsum.ts +++ b/src/modules/image/providers/lorempicsum.ts @@ -86,8 +86,8 @@ export class LoremPicsum { deprecated({ deprecated: 'faker.image.lorempicsum.avatar()', proposed: 'faker.internet.avatar()', - since: 'v7.3.0', - until: 'v8.0.0', + since: '7.3', + until: '8.0', }); return this.faker.internet.avatar(); }