(parent: TestData, isSpecial: boolean = false)
| 711 | } |
| 712 | |
| 713 | addChild(parent: TestData, isSpecial: boolean = false) { |
| 714 | const nextIndex = ++this.dataIndex; |
| 715 | const child = new TestData(`topping_${nextIndex}`, `cheese_${nextIndex}`, `base_${nextIndex}`); |
| 716 | |
| 717 | const index = this.data.indexOf(parent); |
| 718 | if (index > -1) { |
| 719 | parent = new TestData( |
| 720 | parent.pizzaTopping, |
| 721 | parent.pizzaCheese, |
| 722 | parent.pizzaBase, |
| 723 | parent.children, |
| 724 | isSpecial, |
| 725 | ); |
| 726 | } |
| 727 | parent.children.push(child); |
| 728 | parent.observableChildren.next(parent.children); |
| 729 | |
| 730 | let copiedData = this.data.slice(); |
| 731 | if (index > -1) { |
| 732 | copiedData.splice(index, 1, parent); |
| 733 | } |
| 734 | this.data = copiedData; |
| 735 | return child; |
| 736 | } |
| 737 | |
| 738 | addData(isSpecial: boolean = false) { |
| 739 | const nextIndex = ++this.dataIndex; |
no test coverage detected