test(ivy): add attribute interpolation test (#30503)

PR Close #30503
This commit is contained in:
Ben Lesh 2019-05-15 16:41:29 -07:00 committed by Jason Aden
parent d4e6263453
commit 10f48278c2
1 changed files with 51 additions and 0 deletions

View File

@ -98,3 +98,54 @@ describe('attribute binding', () => {
expect(a.href.indexOf('unsafe:')).toBe(-1); expect(a.href.indexOf('unsafe:')).toBe(-1);
}); });
}); });
describe('attribute interpolation', () => {
it('should handle all varieties of interpolation', () => {
@Component({
template: `
<div attr.title="a{{a}}b{{b}}c{{c}}d{{d}}e{{e}}f{{f}}g{{g}}h{{h}}i{{i}}j"></div>
<div attr.title="a{{a}}b{{b}}c{{c}}d{{d}}e{{e}}f{{f}}g{{g}}h{{h}}i"></div>
<div attr.title="a{{a}}b{{b}}c{{c}}d{{d}}e{{e}}f{{f}}g{{g}}h"></div>
<div attr.title="a{{a}}b{{b}}c{{c}}d{{d}}e{{e}}f{{f}}g"></div>
<div attr.title="a{{a}}b{{b}}c{{c}}d{{d}}e{{e}}f"></div>
<div attr.title="a{{a}}b{{b}}c{{c}}d{{d}}e"></div>
<div attr.title="a{{a}}b{{b}}c{{c}}d"></div>
<div attr.title="a{{a}}b{{b}}c"></div>
<div attr.title="a{{a}}b"></div>
<div attr.title="{{a}}"></div>
`
})
class App {
a = 1;
b = 2;
c = 3;
d = 4;
e = 5;
f = 6;
g = 7;
h = 8;
i = 9;
}
TestBed.configureTestingModule({
declarations: [App],
});
const fixture = TestBed.createComponent(App);
fixture.detectChanges();
const divs = fixture.debugElement.queryAll(By.css('div[title]'));
expect(divs.map(el => el.nativeElement.getAttribute('title'))).toEqual([
'a1b2c3d4e5f6g7h8i9j',
'a1b2c3d4e5f6g7h8i',
'a1b2c3d4e5f6g7h',
'a1b2c3d4e5f6g',
'a1b2c3d4e5f',
'a1b2c3d4e',
'a1b2c3d',
'a1b2c',
'a1b',
'1',
]);
});
});