From 85e964c4c5ec632f34d6c905c1fc2dc19366062e Mon Sep 17 00:00:00 2001 From: Eric Cheng Date: Sat, 11 Jun 2022 16:26:18 -0400 Subject: [PATCH 1/7] chore: replace array with getter --- src/modules/image/providers/unsplash.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/modules/image/providers/unsplash.ts b/src/modules/image/providers/unsplash.ts index 45bd815cd40..a06c11ca292 100644 --- a/src/modules/image/providers/unsplash.ts +++ b/src/modules/image/providers/unsplash.ts @@ -4,15 +4,14 @@ import type { Faker } from '../../..'; * Module to generate links to random images on `https://source.unsplash.com/`. */ export class Unsplash { - // TODO ST-DDT 2022-03-11: Remove unused(?) constant - categories = [ - 'food', - 'nature', - 'people', - 'technology', - 'objects', - 'buildings', - ]; + /** + * Gets the list of supported unsplash categories. + * + * @deprecated + */ + get categories(): string[] { + return ['food', 'nature', 'people', 'technology', 'objects', 'buildings']; + } constructor(private readonly faker: Faker) {} From 5feb9bda5eee7ccf046090e1c7a050a02486e118 Mon Sep 17 00:00:00 2001 From: Eric Cheng Date: Sat, 11 Jun 2022 20:44:17 -0400 Subject: [PATCH 2/7] chore: add deprecation log Co-authored-by: xDivisionByZerox --- src/modules/image/providers/unsplash.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/image/providers/unsplash.ts b/src/modules/image/providers/unsplash.ts index a06c11ca292..8513da3f5d8 100644 --- a/src/modules/image/providers/unsplash.ts +++ b/src/modules/image/providers/unsplash.ts @@ -1,4 +1,5 @@ import type { Faker } from '../../..'; +import { deprecated } from '../../../internal/deprecated'; /** * Module to generate links to random images on `https://source.unsplash.com/`. @@ -10,6 +11,11 @@ export class Unsplash { * @deprecated */ get categories(): string[] { + deprecated({ + deprecated: 'faker.image.unsplash.categories', + since: 'v7.2.0', + until: 'v8.0.0', + }); return ['food', 'nature', 'people', 'technology', 'objects', 'buildings']; } From d45a644dff103299e55c4798e8ce599ead8f352e Mon Sep 17 00:00:00 2001 From: Eric Cheng Date: Sun, 12 Jun 2022 09:36:11 -0400 Subject: [PATCH 3/7] test: add deprecation log test Co-authored-by: xDivisionByZerox --- test/image.spec.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/image.spec.ts b/test/image.spec.ts index bbb99ffaaab..1e6e0254c89 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', () => { @@ -155,6 +155,20 @@ describe('image', () => { }); describe('unsplash', () => { + describe('categories', () => { + it('should log a deprecation message', () => { + const consoleSpy = vi.spyOn(console, 'warn'); + + faker.image.unsplash.categories; + + expect(consoleSpy).toHaveBeenCalled(); + + const logMessage = consoleSpy.mock.calls[0][0]; + expect(logMessage).toContain('faker.image.unsplash.categories'); + expect(logMessage).toContain('v7.2.0'); + expect(logMessage).toContain('v8.0.0'); + }); + }); describe('imageUrl()', () => { it('should return a random image url from unsplash', () => { const imageUrl = faker.image.unsplash.imageUrl(); From 6061066b582f33074ce669948e1fd093461cc171 Mon Sep 17 00:00:00 2001 From: Eric Cheng Date: Sun, 12 Jun 2022 16:02:04 -0400 Subject: [PATCH 4/7] Update src/modules/image/providers/unsplash.ts Co-authored-by: Shinigami --- src/modules/image/providers/unsplash.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/image/providers/unsplash.ts b/src/modules/image/providers/unsplash.ts index 8513da3f5d8..79849f408b0 100644 --- a/src/modules/image/providers/unsplash.ts +++ b/src/modules/image/providers/unsplash.ts @@ -13,7 +13,7 @@ export class Unsplash { get categories(): string[] { deprecated({ deprecated: 'faker.image.unsplash.categories', - since: 'v7.2.0', + since: 'v7.3.0', until: 'v8.0.0', }); return ['food', 'nature', 'people', 'technology', 'objects', 'buildings']; From 791a9d9ea706bd4fef5a3ea922bd09927bc35dca Mon Sep 17 00:00:00 2001 From: Eric Cheng Date: Mon, 13 Jun 2022 13:44:12 -0400 Subject: [PATCH 5/7] test: fix test to account for updated version --- test/image.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/image.spec.ts b/test/image.spec.ts index 1e6e0254c89..f4b31c43ba1 100644 --- a/test/image.spec.ts +++ b/test/image.spec.ts @@ -165,7 +165,7 @@ describe('image', () => { const logMessage = consoleSpy.mock.calls[0][0]; expect(logMessage).toContain('faker.image.unsplash.categories'); - expect(logMessage).toContain('v7.2.0'); + expect(logMessage).toContain('v7.3.0'); expect(logMessage).toContain('v8.0.0'); }); }); From b903551745eca55d72774baabca5d9b2781036a1 Mon Sep 17 00:00:00 2001 From: Eric Cheng Date: Tue, 14 Jun 2022 11:47:49 -0400 Subject: [PATCH 6/7] revert: test: image.spec.ts --- test/image.spec.ts | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/test/image.spec.ts b/test/image.spec.ts index f4b31c43ba1..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', () => { @@ -155,20 +155,6 @@ describe('image', () => { }); describe('unsplash', () => { - describe('categories', () => { - it('should log a deprecation message', () => { - const consoleSpy = vi.spyOn(console, 'warn'); - - faker.image.unsplash.categories; - - expect(consoleSpy).toHaveBeenCalled(); - - const logMessage = consoleSpy.mock.calls[0][0]; - expect(logMessage).toContain('faker.image.unsplash.categories'); - expect(logMessage).toContain('v7.3.0'); - expect(logMessage).toContain('v8.0.0'); - }); - }); describe('imageUrl()', () => { it('should return a random image url from unsplash', () => { const imageUrl = faker.image.unsplash.imageUrl(); From 4bb29e219b0e6a820755ebfd63fcb8fa8e8af931 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Tue, 14 Jun 2022 21:06:50 +0200 Subject: [PATCH 7/7] chore: apply suggestions --- src/modules/image/providers/unsplash.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/image/providers/unsplash.ts b/src/modules/image/providers/unsplash.ts index 79849f408b0..e59de17691e 100644 --- a/src/modules/image/providers/unsplash.ts +++ b/src/modules/image/providers/unsplash.ts @@ -13,8 +13,8 @@ export class Unsplash { get categories(): string[] { deprecated({ deprecated: 'faker.image.unsplash.categories', - since: 'v7.3.0', - until: 'v8.0.0', + since: '7.3', + until: '8.0', }); return ['food', 'nature', 'people', 'technology', 'objects', 'buildings']; }