Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(lorempicsum.avatar): deprecate #1065

Merged
merged 7 commits into from
Jun 16, 2022
Merged
12 changes: 11 additions & 1 deletion src/modules/image/providers/lorempicsum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Faker } from '../../..';
import { deprecated } from '../../../internal/deprecated';

/**
* Module to generate links to random images on `https://picsum.photos/`.
Expand Down Expand Up @@ -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()',
import-brain marked this conversation as resolved.
Show resolved Hide resolved
since: 'v7.3.0',
until: 'v8.0.0',
ST-DDT marked this conversation as resolved.
Show resolved Hide resolved
});
return this.faker.internet.avatar();
}

Expand Down
17 changes: 16 additions & 1 deletion test/image.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, it } from 'vitest';
import { describe, expect, it, vi } from 'vitest';
import { faker } from '../src';

describe('image', () => {
Expand Down Expand Up @@ -62,6 +62,21 @@ describe('image', () => {
)
).toBeTruthy();
});

it('should log a deprecation message', () => {
xDivisionByZerox marked this conversation as resolved.
Show resolved Hide resolved
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()', () => {
Expand Down