{"version":3,"sources":["lib/test/util.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAqB7D;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,SAoBxB","file":"../../../lib/test/util.d.ts","sourcesContent":["declare let littleware: any;\n\n/**\n * Get a stage (HTML <section>) where a test can manipulate DOM.  If id is supplied,\n * then return the previously created section with the given id attribute if any -\n * otherwise assign the id to the new stage.\n *\n * @param id optional id to retrieve if present - or assign to new stage\n * @param title optional title (and heading) to attach to a new stage\n * @return HTMLSection\n */\nexport function getStage(id?: string, title?: string): Element {\n  let section = id ? document.body.querySelector(`section[id=\"${id}\"]`) : null;\n  if (section) {\n    return section;\n  }\n  section = document.createElement('section');\n  if (id) { section.setAttribute('id', id); }\n  if (title) {\n    section.setAttribute('title', title);\n    const heading = document.createElement('h2') as HTMLHeadingElement;\n    heading.textContent = title;\n    section.appendChild(heading);\n  }\n  // Place stages before the Jasmin reporting area if present - otherwise append to body\n  const jreport = document.body.querySelector('div[class=\"jasmine_html-reporter\"]');\n  if (jreport) {\n    jreport.parentNode.insertBefore(section, jreport);\n  } else {\n    document.body.appendChild(section);\n  }\n  return section;\n}\n\n/**\n * Little helper to kick off the test runner\n * of the underlying platform.  Assumes\n * either Karma runtime or\n * jasmine brower runtime (via littleJasmineBoot).\n */\nexport function startTest() {\n  // see styleGuide/shell/basicShell.html.njk\n  const shellPromise = globalThis.littleShell ? globalThis.littleShell.clear() as Promise<string> : Promise.resolve('ok');\n\n  shellPromise.then(\n    () => {\n      if (globalThis.littleware && littleware.test && littleware.test.startJasmine) {\n        // This is not necessary when running with Karma ...\n        // eslint-disable-next-line\n        console.log('Bootstrapping jasmine');\n        littleware.test.startJasmine();\n      } else if (typeof (window as any).__karma__ !== 'undefined') {\n        // eslint-disable-next-line\n        console.log('Bootstrapping karma which is natively module aware');\n      } else {\n        // eslint-disable-next-line\n        console.log('No test bootstrap present on page');\n      }\n    },\n  );\n}\n"]}