Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
codenirvana committed Jul 29, 2024
1 parent dc49d68 commit 4efaeb5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
6 changes: 2 additions & 4 deletions CHANGELOG.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
unreleased:
fixed-bug:
- >-
GH-1366 Fixed a bug where $randomAvatarImage was returning an invalid URL.
fixed bugs:
- GH-1366 Fixed a bug where $randomAvatarImage was returning an invalid URL

4.4.0:
date: 2024-02-28
Expand Down
11 changes: 6 additions & 5 deletions lib/superstring/dynamic-variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,24 @@ var faker = require('@faker-js/faker/locale/en'),
],

/**
* Copied over from: https://github.com/faker-js/faker/blob/next/src/modules/image/index.ts#L27
* Generates a random avatar from GitHub.
*
* Ref: https://github.com/faker-js/faker/blob/v8.4.1/src/modules/image/index.ts#L79
*
* @private
* @example 'https://avatars.githubusercontent.com/u/97165289'
*/
avatarGitHub = () => {
return `https://avatars.githubusercontent.com/u/${faker.datatype.number(100000000)}`;
},

/**
* Copied over from: https://github.com/faker-js/faker/blob/next/src/modules/image/index.ts#L27
* Generates a random avatar from
* `https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar`.
*
* Ref: https://github.com/faker-js/faker/blob/v8.4.1/src/modules/image/index.ts#L95
*
* @private
* @example 'https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/170.jpg'
*/
avatarLegacy = () => {
Expand Down Expand Up @@ -394,9 +398,6 @@ var faker = require('@faker-js/faker/locale/en'),
$randomAvatarImage: {
description: 'A random avatar image',
generator: () => {
// We have overridden the avatar generator to be similar to current
// latest version (v9) of faker.js. We don't want to upgrade to the latest
// version of faker.js as it is significantly big in size.
const avatarMethod = faker.random.arrayElement([
avatarLegacy,
avatarGitHub
Expand Down
4 changes: 2 additions & 2 deletions test/unit/dynamic-variables.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ describe('Dynamic variable', function () {
it('$randomAvatarImage returns a random avatar image', function () {
var avatarImage = dynamicVariables.$randomAvatarImage.generator();

expect(avatarImage).to.not.be.undefined;
expect(avatarImage).to.not.be.null;
expect(avatarImage).to.be.a('string')
.and.match(/^https:\/\/(avatars\.githubusercontent\.com|cloudflare-ipfs\.com)\/.+/);
});
});
});

0 comments on commit 4efaeb5

Please sign in to comment.