|
11 | 11 | package org.eclipse.angularjs.core.utils; |
12 | 12 |
|
13 | 13 | import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; |
| 14 | +import org.junit.Assert; |
14 | 15 | import org.junit.Test; |
15 | 16 |
|
16 | 17 | public class AngularRegionUtilsTest { |
17 | 18 |
|
18 | 19 | @Test |
19 | | - public void test() { |
| 20 | + public void offsetBeforeStartEL() { |
| 21 | + AngularELRegion region = AngularRegionUtils.getAngularELRegion( |
| 22 | + DOMRegionContext.XML_CONTENT, "{{todo.text + to}}", 588, 588, |
| 23 | + "{{", "}}"); |
| 24 | + Assert.assertNull(region); |
| 25 | + } |
| 26 | + |
| 27 | + @Test |
| 28 | + public void offsetAfterStartEL() { |
| 29 | + AngularELRegion region = AngularRegionUtils.getAngularELRegion( |
| 30 | + DOMRegionContext.XML_CONTENT, "{{todo.text + to}}", 588, 590, |
| 31 | + "{{", "}}"); |
| 32 | + Assert.assertNotNull(region); |
| 33 | + Assert.assertEquals("todo.text + to", region.getExpression()); |
| 34 | + Assert.assertEquals(0, region.getExpressionOffset()); |
| 35 | + } |
| 36 | + |
| 37 | + @Test |
| 38 | + public void offsetBeforeEndEL() { |
| 39 | + AngularELRegion region = AngularRegionUtils.getAngularELRegion( |
| 40 | + DOMRegionContext.XML_CONTENT, "{{todo.text + to}}", 588, 603, |
| 41 | + "{{", "}}"); |
| 42 | + Assert.assertNull(region); |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + public void offsetAfterEndEL() { |
20 | 47 | AngularELRegion region = AngularRegionUtils.getAngularELRegion( |
21 | 48 | DOMRegionContext.XML_CONTENT, "{{todo.text + to}}", 588, 604, |
22 | 49 | "{{", "}}"); |
| 50 | + Assert.assertNotNull(region); |
| 51 | + Assert.assertEquals("todo.text + to", region.getExpression()); |
| 52 | + Assert.assertEquals(14, region.getExpressionOffset()); |
| 53 | + } |
| 54 | + |
| 55 | + @Test |
| 56 | + public void test2() { |
| 57 | + AngularELRegion region = AngularRegionUtils.getAngularELRegion( |
| 58 | + DOMRegionContext.XML_CONTENT, "{{", 588, 604, "{{", "}}"); |
| 59 | + Assert.assertNull(region); |
23 | 60 | } |
24 | 61 | } |
0 commit comments