2019-09-08 11:26:23 -04:00
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2019-09-08 11:26:23 -04:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {Component} from '@angular/core';
|
|
|
|
import {getLContext} from '@angular/core/src/render3/context_discovery';
|
|
|
|
import {LViewDebug, toDebug} from '@angular/core/src/render3/instructions/lview_debug';
|
|
|
|
import {TestBed} from '@angular/core/testing';
|
|
|
|
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
|
|
|
import {onlyInIvy} from '@angular/private/testing';
|
|
|
|
|
|
|
|
describe('Debug Representation', () => {
|
|
|
|
onlyInIvy('Ivy specific').it('should generate a human readable version', () => {
|
|
|
|
@Component({selector: 'my-comp', template: '<div id="123">Hello World</div>'})
|
|
|
|
class MyComponent {
|
|
|
|
}
|
|
|
|
|
|
|
|
TestBed.configureTestingModule({declarations: [MyComponent]});
|
|
|
|
const fixture = TestBed.createComponent(MyComponent);
|
|
|
|
fixture.detectChanges();
|
|
|
|
|
2020-04-13 19:40:21 -04:00
|
|
|
const hostView = toDebug(getLContext(fixture.componentInstance)!.lView);
|
2019-09-08 11:26:23 -04:00
|
|
|
expect(hostView.host).toEqual(null);
|
|
|
|
const myCompView = hostView.childViews[0] as LViewDebug;
|
|
|
|
expect(myCompView.host).toContain('<div id="123">Hello World</div>');
|
2020-04-13 19:40:21 -04:00
|
|
|
expect(myCompView.nodes![0].html).toEqual('<div id="123">');
|
|
|
|
expect(myCompView.nodes![0].nodes![0].html).toEqual('Hello World');
|
2019-09-08 11:26:23 -04:00
|
|
|
});
|
|
|
|
});
|