Add group factory functions for tests, add a groupSchema test See merge request soapbox-pub/soapbox!2344environments/review-develop-3zknud/deployments/2843
commit
6ac57910bf
@ -0,0 +1,16 @@
|
||||
{
|
||||
"note": "patriots 900000001",
|
||||
"discoverable": true,
|
||||
"id": "109989480368015378",
|
||||
"domain": null,
|
||||
"avatar": "https://media.covfefe.social/groups/avatars/109/989/480/368/015/378/original/50b0d899bc5aae13.jpg",
|
||||
"avatar_static": "https://media.covfefe.social/groups/avatars/109/989/480/368/015/378/original/50b0d899bc5aae13.jpg",
|
||||
"header": "https://media.covfefe.social/groups/headers/109/989/480/368/015/378/original/c5063b59f919cd4a.png",
|
||||
"header_static": "https://media.covfefe.social/groups/headers/109/989/480/368/015/378/original/c5063b59f919cd4a.png",
|
||||
"group_visibility": "everyone",
|
||||
"created_at": "2023-03-08T00:00:00.000Z",
|
||||
"display_name": "PATRIOT PATRIOTS",
|
||||
"membership_required": true,
|
||||
"members_count": 1,
|
||||
"tags": []
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { groupSchema, Group, groupRelationshipSchema, GroupRelationship } from 'soapbox/schemas';
|
||||
|
||||
// TODO: there's probably a better way to create these factory functions.
|
||||
// This looks promising but didn't work on my first attempt: https://github.com/anatine/zod-plugins/tree/main/packages/zod-mock
|
||||
|
||||
function buildGroup(props: Record<string, any> = {}): Group {
|
||||
return groupSchema.parse(Object.assign({
|
||||
id: uuidv4(),
|
||||
}, props));
|
||||
}
|
||||
|
||||
function buildGroupRelationship(props: Record<string, any> = {}): GroupRelationship {
|
||||
return groupRelationshipSchema.parse(Object.assign({
|
||||
id: uuidv4(),
|
||||
}, props));
|
||||
}
|
||||
|
||||
export { buildGroup, buildGroupRelationship };
|
@ -0,0 +1,7 @@
|
||||
import { groupSchema } from '../group';
|
||||
|
||||
test('groupSchema with a TruthSocial group', () => {
|
||||
const data = require('soapbox/__fixtures__/group-truthsocial.json');
|
||||
const group = groupSchema.parse(data);
|
||||
expect(group.display_name_html).toEqual('PATRIOT PATRIOTS');
|
||||
});
|
Loading…
Reference in new issue