{"version":3,"file":"babybeet-angular-testing-kit.mjs","sources":["../../../projects/angular-testing-kit/src/lib/assert-that/matchers/does-not-exist.ts","../../../projects/angular-testing-kit/src/lib/assert-that/matchers/exists.ts","../../../projects/angular-testing-kit/src/lib/assert-that/matchers/index.ts","../../../projects/angular-testing-kit/src/lib/assert-that/debug-element-assert-that.ts","../../../projects/angular-testing-kit/src/lib/get-element-by-selector.ts","../../../projects/angular-testing-kit/src/lib/extract-text-content.ts","../../../projects/angular-testing-kit/src/lib/find-element-by-selector.ts","../../../projects/angular-testing-kit/src/lib/assert-that/selector-assert-that.ts","../../../projects/angular-testing-kit/src/lib/assert-that/assert-that.ts","../../../projects/angular-testing-kit/src/lib/assert-that/index.ts","../../../projects/angular-testing-kit/src/lib/delay-by.ts","../../../projects/angular-testing-kit/src/lib/fire-event.ts","../../../projects/angular-testing-kit/src/babybeet-angular-testing-kit.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport { DebugElement } from '@angular/core';\nimport { html_beautify } from 'js-beautify';\n\nexport const doesNotExistMatcher = {\n  compare(actual: Element | DebugElement | null, selector?: string) {\n    const result: jasmine.CustomMatcherResult = {\n      error: undefined,\n      message: '',\n      pass: actual === null\n    };\n\n    if (actual instanceof Element) {\n      result.message = `Expected a DOM element for selector '${String(selector)}' to not exist`;\n\n      if (!result.pass) {\n        const prettifiedHtml = html_beautify(actual.outerHTML, { end_with_newline: true, indent_size: 2 });\n\n        result.error = new Error(\n          `${result.message}, but it was present (it should have been null). It was\\n${prettifiedHtml}`\n        );\n      }\n    } else {\n      result.message = 'Expected debug element to not exist';\n\n      if (!result.pass) {\n        const prettifiedHtml = html_beautify(actual?.nativeElement.outerHTML, {\n          end_with_newline: true,\n          indent_size: 2\n        });\n\n        result.error = new Error(\n          `${result.message}, but it was present (it should have been null). It was\\n${prettifiedHtml}`\n        );\n      }\n    }\n\n    return result;\n  }\n};\n","import { DebugElement } from '@angular/core';\n\nexport const existsMatcher = {\n  compare(actual: Element | DebugElement | null, selector?: string) {\n    const result: jasmine.CustomMatcherResult = {\n      error: undefined,\n      message: '',\n      pass: actual !== null\n    };\n\n    if (typeof selector === 'string') {\n      result.message = `Expected DOM element for '${selector}' to exist`;\n\n      if (!result.pass) {\n        /*\n         * Without the new line character at the end, this error message doesn't show when this assertion fails.\n         */\n        result.error = new Error(`${result.message}, but it was missing (it should not have been null})\\n`);\n      }\n    } else {\n      result.message = 'Expected debug element to exist';\n\n      if (!result.pass) {\n        result.error = new Error(`${result.message}, but it was missing (it should not have been null)\\n`);\n      }\n    }\n\n    return result;\n  }\n};\n","import { doesNotExistMatcher } from './does-not-exist';\nimport { existsMatcher } from './exists';\n\nexport const matchers = {\n  doesNotExist() {\n    return doesNotExistMatcher;\n  },\n  exists() {\n    return existsMatcher;\n  }\n};\n","import { DebugElement } from '@angular/core';\n\nimport { AssertThatApi } from './assert-that-api';\n\nexport class DebugElementAssertThat implements AssertThatApi {\n  constructor(private readonly _debugElement: DebugElement | null | undefined) {}\n\n  doesNotExist() {\n    expect(this._debugElement).doesNotExist();\n  }\n\n  exists() {\n    expect(this._debugElement).exists();\n  }\n\n  hasInnerHtml(expected: string) {\n    this._throwIfDebugElementIsNullOrUndefined();\n\n    expect(this._debugElement?.nativeElement.innerHTML).toEqual(expected);\n  }\n\n  private _throwIfDebugElementIsNullOrUndefined() {\n    if (this._debugElement === null) {\n      throw new Error('Debug element is null');\n    }\n\n    if (this._debugElement === undefined) {\n      throw new Error('Debug element is undefined');\n    }\n  }\n\n  hasTextContent(expected: string) {\n    this._throwIfDebugElementIsNullOrUndefined();\n\n    expect(this._debugElement?.nativeElement.textContent).toEqual(expected);\n  }\n\n  hasTextContentMatching(expected: string | RegExp) {\n    this._throwIfDebugElementIsNullOrUndefined();\n\n    expect(this._debugElement?.nativeElement.textContent).toMatch(expected);\n  }\n}\n","/**\n * Retrieve the DOM element matched by `selector`. If nothing is found, an error will be thrown.\n *\n * @param selector HTML selector to match.\n *\n * @returns The matched DOM element.\n */\nexport function getElementBySelector(selector: string) {\n  const element = document.body.querySelector(selector);\n\n  if (element === null) {\n    throw new Error(`No element with selector '${selector}' was found`);\n  }\n\n  return element as HTMLElement;\n}\n","import { getElementBySelector } from './get-element-by-selector';\n\n/**\n * Return the text content of the element matched by `selector`. Will throw an error if the matched element\n * is a `document` or `doctype` node. If no element is matched, then an error will be thrown.\n *\n * @param selector HTML selector to match.\n *\n * @returns The text content of the match element.\n */\nexport function extractTextContent(selector: string) {\n  const textContent = getElementBySelector(selector).textContent;\n\n  if (textContent !== null) {\n    return textContent;\n  }\n\n  throw new Error(\n    // eslint-disable-next-line max-len\n    `Text content of element with selector '${selector}' is null, ensure that the target element is neither a document nor a doctype`\n  );\n}\n","/**\n * Find the element matched by the provided selector. If nothing is matched, `null` is returned.\n *\n * @param selector HTML selector to match.\n */\nexport function findElementBySelector(selector: string) {\n  return document.body.querySelector(selector) as HTMLElement | null;\n}\n","/// <reference path=\"types.d.ts\"/>\n\nimport { extractTextContent } from '../extract-text-content';\nimport { findElementBySelector } from '../find-element-by-selector';\nimport { getElementBySelector } from '../get-element-by-selector';\n\nimport { AssertThatApi } from './assert-that-api';\n\nexport class SelectorAssertThat implements AssertThatApi {\n  constructor(private readonly _selector: string) {}\n\n  doesNotExist() {\n    expect(findElementBySelector(this._selector)).doesNotExist(this._selector);\n  }\n\n  exists() {\n    expect(findElementBySelector(this._selector)).exists(this._selector);\n  }\n\n  hasInnerHtml(expected: string) {\n    expect(getElementBySelector(this._selector).innerHTML).toEqual(expected);\n  }\n\n  hasTextContent(expected: string) {\n    expect(extractTextContent(this._selector)).toEqual(expected);\n  }\n\n  hasTextContentMatching(expected: string | RegExp) {\n    expect(extractTextContent(this._selector)).toMatch(expected);\n  }\n}\n","import { DebugElement } from '@angular/core';\n\nimport { AssertThatApi } from './assert-that-api';\nimport { DebugElementAssertThat } from './debug-element-assert-that';\nimport { SelectorAssertThat } from './selector-assert-that';\n\nexport function assertThat(selector: string | DebugElement | null | undefined): AssertThatApi {\n  return typeof selector === 'string' ? new SelectorAssertThat(selector) : new DebugElementAssertThat(selector);\n}\n","import { matchers } from './matchers';\n\nexport * from './assert-that';\n\nbeforeEach(() => {\n  jasmine.addMatchers(matchers);\n});\n","/**\n * Wait until `delayMs` milliseconds have passed before proceeding.\n *\n * @param delayMs The number of milliseconds to wait for.\n *\n * @returns A promise that will resolve once `delayMs` milliseconds have passed.\n */\nexport function delayBy(delayMs: number) {\n  return new Promise<void>(resolve => setTimeout(resolve, delayMs));\n}\n","import { DebugElement } from '@angular/core';\n\nimport { getElementBySelector } from './get-element-by-selector';\n\n/**\n * Dispatch the given `eventType` DOM event on the target element matched by the provided selector.\n * The selector argument accepts 3 different types of value:\n *  - If it's a string, then it's treated as an HTML selector by which to find the target element\n *    to fire the event on. If no element is found for the provided selector,\n *    then an error will be thrown.\n *  - If it's an {@link EventTarget} such as {@link Element} or {@link window},\n *    then the event is fired directly on it.\n *  - If it's a {@link DebugElement}, then its native element will be dispatched the event on.\n *\n * @param selector HTML selector to match.\n * @param eventType DOM element type such as `click`, `pointerup`, etc.\n * @param eventDetail Optional event detail to include such as the key code for keyboard event.\n */\nexport function fireEvent<T extends keyof HTMLElementEventMap = keyof HTMLElementEventMap>(\n  selector: string | EventTarget | DebugElement | null | undefined,\n  eventType: T,\n  eventDetail?: CustomEventInit<HTMLElementEventMap[T]>['detail']\n) {\n  if (typeof selector === 'string') {\n    getElementBySelector(selector).dispatchEvent(new CustomEvent(eventType as string, { detail: eventDetail }));\n  } else if (selector instanceof EventTarget) {\n    selector.dispatchEvent(new CustomEvent(eventType as string, { detail: eventDetail }));\n  } else if (selector instanceof DebugElement) {\n    selector.nativeElement.dispatchEvent(new CustomEvent(eventType as string, { detail: eventDetail }));\n  } else {\n    throw new Error(\n      `The event target for the provided selector is not a string, Element, or DebugElement, it was ${String(selector)}`\n    );\n  }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAIO,MAAM,mBAAmB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