Correct commentTree failure unit-test - issue #1776
This commit is contained in:
@@ -1,24 +1,73 @@
|
||||
import { CURRENT_ACTOR_CLIENT } from "@/graphql/actor";
|
||||
import { CURRENT_USER_LOCATION_CLIENT } from "@/graphql/location";
|
||||
import { CURRENT_USER_CLIENT } from "@/graphql/user";
|
||||
import { ICurrentUserRole } from "@/types/enums";
|
||||
import {
|
||||
ApolloCache,
|
||||
NormalizedCacheObject,
|
||||
Resolver,
|
||||
type Resolvers,
|
||||
} from "@apollo/client";
|
||||
|
||||
export const defaultResolvers = {
|
||||
Query: {
|
||||
currentUser: (): Record<string, any> => ({
|
||||
email: "user@mail.com",
|
||||
id: "2",
|
||||
role: ICurrentUserRole.USER,
|
||||
isLoggedIn: true,
|
||||
__typename: "CurrentUser",
|
||||
}),
|
||||
currentActor: (): Record<string, any> => ({
|
||||
id: "67",
|
||||
preferredUsername: "someone",
|
||||
name: "Personne",
|
||||
avatar: null,
|
||||
__typename: "CurrentActor",
|
||||
}),
|
||||
},
|
||||
export const fakeCurrentUserData: Resolver = (): Record<string, any> => {
|
||||
return {
|
||||
__typename: "CurrentUser",
|
||||
id: "2",
|
||||
email: "user@mail.com",
|
||||
role: ICurrentUserRole.USER,
|
||||
isLoggedIn: true,
|
||||
};
|
||||
};
|
||||
|
||||
export const fakeCurrentActorData: Resolver = (): Record<string, any> => {
|
||||
return {
|
||||
__typename: "CurrentActor",
|
||||
id: "67",
|
||||
preferredUsername: "someone",
|
||||
name: "Personne",
|
||||
avatar: null,
|
||||
};
|
||||
};
|
||||
|
||||
export function defaultResolvers(
|
||||
cache: ApolloCache<NormalizedCacheObject>
|
||||
): Resolvers {
|
||||
cache?.writeQuery({
|
||||
query: CURRENT_USER_CLIENT,
|
||||
data: {
|
||||
currentUser: fakeCurrentUserData(),
|
||||
},
|
||||
});
|
||||
|
||||
cache?.writeQuery({
|
||||
query: CURRENT_ACTOR_CLIENT,
|
||||
data: {
|
||||
currentActor: fakeCurrentActorData(),
|
||||
},
|
||||
});
|
||||
|
||||
cache?.writeQuery({
|
||||
query: CURRENT_USER_LOCATION_CLIENT,
|
||||
data: {
|
||||
currentUserLocation: {
|
||||
lat: null,
|
||||
lon: null,
|
||||
accuracy: null,
|
||||
isIPLocation: null,
|
||||
name: null,
|
||||
picture: null,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
Query: {
|
||||
currentUser: fakeCurrentUserData,
|
||||
currentActor: fakeCurrentActorData,
|
||||
},
|
||||
} satisfies Resolvers;
|
||||
}
|
||||
|
||||
export const nullMock = {
|
||||
data: {},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user