| 594 | } |
| 595 | |
| 596 | class MockRenderer implements Renderer2 { |
| 597 | public spies: {[methodName: string]: any} = {}; |
| 598 | data = {}; |
| 599 | |
| 600 | destroyNode: ((node: any) => void) | null = null; |
| 601 | |
| 602 | constructor( |
| 603 | spyOnMethods: string[], |
| 604 | private document: Document, |
| 605 | ) { |
| 606 | spyOnMethods.forEach((methodName) => { |
| 607 | this.spies[methodName] = spyOn(this as any, methodName).and.callThrough(); |
| 608 | }); |
| 609 | } |
| 610 | |
| 611 | destroy(): void {} |
| 612 | createComment(value: string): Comment { |
| 613 | return this.document.createComment(value); |
| 614 | } |
| 615 | createElement(name: string, namespace?: string | null): Element { |
| 616 | return namespace |
| 617 | ? this.document.createElementNS(namespace, name) |
| 618 | : this.document.createElement(name); |
| 619 | } |
| 620 | createText(value: string): Text { |
| 621 | return this.document.createTextNode(value); |
| 622 | } |
| 623 | appendChild(parent: RElement, newChild: Node): void { |
| 624 | parent.appendChild(newChild); |
| 625 | } |
| 626 | insertBefore(parent: Node, newChild: Node, refChild: Node | null): void { |
| 627 | parent.insertBefore(newChild, refChild); |
| 628 | } |
| 629 | removeChild(parent: RElement, oldChild: Element): void { |
| 630 | oldChild.remove(); |
| 631 | } |
| 632 | selectRootElement(selectorOrNode: string | any): RElement { |
| 633 | return typeof selectorOrNode === 'string' |
| 634 | ? this.document.querySelector<HTMLElement>(selectorOrNode)! |
| 635 | : selectorOrNode; |
| 636 | } |
| 637 | parentNode(node: Node): Element | null { |
| 638 | return node.parentNode as Element; |
| 639 | } |
| 640 | nextSibling(node: Node): Node | null { |
| 641 | return node.nextSibling; |
| 642 | } |
| 643 | setAttribute(el: RElement, name: string, value: string, namespace?: string | null): void { |
| 644 | // set all synthetic attributes as properties |
| 645 | if (name[0] === '@') { |
| 646 | this.setProperty(el, name, value); |
| 647 | } else { |
| 648 | el.setAttribute(name, value); |
| 649 | } |
| 650 | } |
| 651 | removeAttribute(el: RElement, name: string, namespace?: string | null): void {} |
| 652 | addClass(el: RElement, name: string): void {} |
| 653 | removeClass(el: RElement, name: string): void {} |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…