Display user badges
This commit is contained in:
parent
927c22ef73
commit
f647c4e053
95 changed files with 2891 additions and 424 deletions
42
ts/test-both/helpers/getFakeBadge.ts
Normal file
42
ts/test-both/helpers/getFakeBadge.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { times } from 'lodash';
|
||||
import type { BadgeType } from '../../badges/types';
|
||||
import { BadgeCategory } from '../../badges/BadgeCategory';
|
||||
import { BadgeImageTheme } from '../../badges/BadgeImageTheme';
|
||||
import { repeat, zipObject } from '../../util/iterables';
|
||||
|
||||
export function getFakeBadge({
|
||||
alternate = false,
|
||||
id = 'test-badge',
|
||||
}: Readonly<{
|
||||
alternate?: boolean;
|
||||
id?: string;
|
||||
}> = {}): BadgeType {
|
||||
const imageFile = {
|
||||
localPath: `/fixtures/${alternate ? 'blue' : 'orange'}-heart.svg`,
|
||||
url: 'https://example.com/ignored.svg',
|
||||
};
|
||||
|
||||
return {
|
||||
id,
|
||||
category: alternate ? BadgeCategory.Other : BadgeCategory.Donor,
|
||||
name: `Test Badge ${alternate ? 'B' : 'A'}`,
|
||||
descriptionTemplate: '{short_name} got this badge for no good reason',
|
||||
images: [
|
||||
...Array(3).fill(
|
||||
zipObject(Object.values(BadgeImageTheme), repeat(imageFile))
|
||||
),
|
||||
{ [BadgeImageTheme.Transparent]: imageFile },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
export const getFakeBadges = (count: number): Array<BadgeType> =>
|
||||
times(count, index =>
|
||||
getFakeBadge({
|
||||
alternate: index % 2 !== 0,
|
||||
id: `test-badge-${index}`,
|
||||
})
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue