Every method the components can reach, and a record of which ones they did.
()
| 302 | |
| 303 | /** Every method the components can reach, and a record of which ones they did. */ |
| 304 | function mockAdapter(): { adapter: GraphAdapter; calls: string[] } { |
| 305 | const calls: string[] = []; |
| 306 | const seen = <T>(name: string, value: T): Promise<T> => { |
| 307 | calls.push(name); |
| 308 | return Promise.resolve(value); |
| 309 | }; |
| 310 | const adapter: GraphAdapter = { |
| 311 | stats: () => seen('stats', STATS), |
| 312 | search: () => |
| 313 | seen('search', { |
| 314 | query: '', |
| 315 | text: '', |
| 316 | filters: { kinds: [], languages: [], paths: [], names: [] }, |
| 317 | results: { total: 0, shown: 0, truncated: false, items: [] }, |
| 318 | groups: [], |
| 319 | }), |
| 320 | node: (id) => { |
| 321 | calls.push(`node:${id}`); |
| 322 | return Promise.resolve(SYMBOL); |
| 323 | }, |
| 324 | nodes: () => seen('nodes', { items: [], missing: [] }), |
| 325 | source: (request) => { |
| 326 | calls.push(`source:${request.file}`); |
| 327 | return Promise.resolve(SOURCE); |
| 328 | }, |
| 329 | file: () => |
| 330 | seen('file', { |
| 331 | file: { |
| 332 | path: 'src/auth/token.ts', |
| 333 | language: 'typescript', |
| 334 | size: 900, |
| 335 | modifiedAt: 0, |
| 336 | indexedAt: 0, |
| 337 | contentHash: 'abc123', |
| 338 | nodeCount: 3, |
| 339 | generated: false, |
| 340 | test: false, |
| 341 | errors: [], |
| 342 | id: 'file:src/auth/token.ts', |
| 343 | }, |
| 344 | topLevel: { calls: 0 }, |
| 345 | drift: false, |
| 346 | outline: { total: 0, shown: 0, truncated: false, items: [] }, |
| 347 | imports: { total: 0, shown: 0, truncated: false, items: [] }, |
| 348 | importedBy: { total: 0, shown: 0, truncated: false, items: [] }, |
| 349 | unresolvedImports: [], |
| 350 | dependencies: [], |
| 351 | dependents: [], |
| 352 | }), |
| 353 | fileCode: () => |
| 354 | seen('fileCode', { |
| 355 | file: { |
| 356 | path: 'src/auth/token.ts', |
| 357 | language: 'typescript', |
| 358 | size: 900, |
| 359 | indexedAt: 0, |
| 360 | contentHash: 'abc123', |
| 361 | generated: false, |
no test coverage detected