MCPcopy
hub / github.com/npmx-dev/npmx.dev / getPooledResults

Function getPooledResults

test/nuxt/a11y.spec.ts:4531–4560  ·  view source on GitHub ↗
(colorMode: string, bgTheme: string)

Source from the content-addressed store, hash-verified

4529 const pooledResults = new Map<string, Promise<AxeResults>>()
4530
4531 function getPooledResults(colorMode: string, bgTheme: string) {
4532 const key = `${colorMode}:${bgTheme}`
4533 const cached = pooledResults.get(key)
4534 if (cached) return cached
4535
4536 const promise = (async () => {
4537 const wrappers = await Promise.all(components.map(({ mount }) => mount()))
4538 const poolContainer = document.createElement('div')
4539 poolContainer.id = `a11y-theme-pool-${colorMode}-${bgTheme}`
4540 document.body.appendChild(poolContainer)
4541 mountedContainers.push(poolContainer)
4542
4543 try {
4544 for (const wrapper of wrappers) {
4545 const el = wrapper.element.cloneNode(true) as HTMLElement
4546 poolContainer.appendChild(el)
4547 }
4548
4549 await nextTick()
4550 return await axe.run(poolContainer, axeRunOptions)
4551 } finally {
4552 for (const wrapper of wrappers) {
4553 wrapper.unmount()
4554 }
4555 }
4556 })()
4557
4558 pooledResults.set(key, promise)
4559 return promise
4560 }
4561
4562 for (const { name, mount } of components) {
4563 describe(`${name} colors`, () => {

Callers 1

a11y.spec.tsFile · 0.85

Calls 2

getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected