MCPcopy Create free account
hub / github.com/emwalker/digraph / makeMocks

Function makeMocks

client/src/components/TopicPage/ViewTopicPage/index.test.tsx:98–151  ·  view source on GitHub ↗
(environment: MockEnvironment, options?: Options)

Source from the content-addressed store, hash-verified

96}
97
98function makeMocks(environment: MockEnvironment, options?: Options) {
99 const repoIds = options?.repoIds || ['wiki-repo-id']
100 const selectedRepoId = options?.selectedRepoId !== undefined
101 ? options?.selectedRepoId
102 : 'wiki-repo-id'
103
104 return () => {
105 environment.mock.resolveMostRecentOperation((operation) =>
106 MockPayloadGenerator.generate(operation, {
107 Topic(context) {
108 return {
109 __typename: 'Topic',
110 children: childrenFor(context),
111 displayName: 'Existing topic',
112 displayParentTopics: [],
113 displaySynonyms: [],
114 id: 'topic-id',
115 repoTopics: repoIds.map((repoId) => ({
116 repoId,
117 repo: {
118 name: repoId,
119 id: repoId,
120 },
121 })),
122 viewerCanUpdate: true,
123 }
124 },
125
126 Link() {
127 return {
128 __typename: 'Link',
129 id: 'link-id',
130 displayTitle: 'Existing link',
131 displayUrl: 'https://www.reddit.com',
132 viewerCanUpdate: true,
133 displayParentTopics: [],
134 }
135 },
136
137 User() {
138 const isPrivate = selectedRepoId !== 'wiki-repo-id'
139 return {
140 id: 'viewer-id',
141 selectedRepoId,
142 selectedRepo: selectedRepoId == null ? null : {
143 id: selectedRepoId,
144 isPrivate,
145 },
146 }
147 },
148 }),
149 )
150 }
151}
152
153describe('<ViewTopicPage>', () => {
154 describe('a simple case', () => {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected