also looking at this
fix(loops): render the row a @break or @continue stops in
#2102
2 files
+89
-43
| @@ -745,6 +745,67 @@ describe('Loops Comprehensive', () => { | ||
| 745 | 745 | }) |
| 746 | 746 | }) |
| 747 | 747 | |
| 748 | // =========================================================================== | |
| 749 | // Content before @break and @continue | |
| 750 | // =========================================================================== | |
| 751 | describe('content before @break and @continue', () => { | |
| 752 | it('should render the row an unconditional @break stops', () => { | |
| 753 | const result = run( | |
| 754 | ``, | |
| 755 | { items: ['a', 'b', 'c'] }, | |
| 756 | ) | |
| 757 | expect(result).toBe('<li>a</li><li>b</li>') | |
| 758 | }) | |
| 759 | ||
| 760 | it('should render the row a conditional @break(condition) stops', () => { | |
| 761 | const result = run( | |
| 762 | '', | |
| 763 | { items: [1, 2, 3] }, | |
| 764 | ) | |
| 765 | expect(result).toBe('<li>1</li><i>1</i><li>2</li>') | |
| 766 | }) | |
| 767 | ||
| 768 | it('should process directives in the row a conditional @break(condition) stops', () => { | |
| 769 | const result = run( | |
| 770 | '', | |
| 771 | { items: [1, 2, 3] }, | |
| 772 | ) | |
| 773 | expect(result).toBe('<b>2</b>') | |
| 774 | }) | |
| 775 | ||
| 776 | it('should render the row an unconditional @continue skips the rest of', () => { | |
| 777 | const result = run( | |
| 778 | ``, | |
| 779 | { items: ['a', 'b', 'c'] }, | |
| 780 | ) | |
| 781 | expect(result).toBe('<li>a</li><i>a</i><li>b</li><li>c</li><i>c</i>') | |
| 782 | }) | |
| 783 | ||
| 784 | it('should render the row a conditional @continue(condition) skips the rest of', () => { | |
| 785 | const result = run( | |
| 786 | '', | |
| 787 | { items: [1, 2, 3] }, | |
| 788 | ) | |
| 789 | expect(result).toBe('<li>1</li><i>1</i><li>2</li><li>3</li><i>3</i>') | |
| 790 | }) | |
| 791 | ||
| 792 | it('should stop at whichever of @break and @continue comes first in the row', () => { | |
| 793 | const result = run( | |
| 794 | '', | |
| 795 | { items: [1, 2, 3] }, | |
| 796 | ) | |
| 797 | expect(result).toBe('<li>1</li><i>1</i><li>2</li>') | |
| 798 | }) | |
| 799 | ||
| 800 | it('should let a @continue inside @if win over a later @break(condition)', () => { | |
| 801 | const result = run( | |
| 802 | '', | |
| 803 | { items: [1, 2, 3] }, | |
| 804 | ) | |
| 805 | expect(result).toBe('<li>1</li><i>1</i><li>2</li><li>3</li><i>3</i>') | |
| 806 | }) | |
| 807 | }) | |
| 808 | ||
| 748 | 809 | // =========================================================================== |
| 749 | 810 | // Prop Bindings in Loops |
| 750 | 811 | // =========================================================================== |