test(core): properly stringify HTML elements in render3 tests (#21279)

PR Close #21279
This commit is contained in:
Marc Laval
2018-01-03 11:42:48 +01:00
committed by Kara Erickson
parent d2cfc6a719
commit a2f3f4550d
8 changed files with 29 additions and 18 deletions

View File

@ -11,7 +11,7 @@ import {D, E, T, b, defineComponent, e, markDirty, t} from '../../src/render3/in
import {createRendererType2} from '../../src/view/index';
import {getRendererFactory2} from './imported_renderer2';
import {containerEl, renderComponent, requestAnimationFrame} from './render_util';
import {containerEl, renderComponent, requestAnimationFrame, toHtml} from './render_util';
describe('component', () => {
class CounterComponent {
@ -37,22 +37,22 @@ describe('component', () => {
describe('renderComponent', () => {
it('should render on initial call', () => {
renderComponent(CounterComponent);
expect(containerEl.innerHTML).toEqual('0');
expect(toHtml(containerEl)).toEqual('0');
});
it('should re-render on input change or method invocation', () => {
const component = renderComponent(CounterComponent);
expect(containerEl.innerHTML).toEqual('0');
expect(toHtml(containerEl)).toEqual('0');
component.count = 123;
markDirty(component, requestAnimationFrame);
expect(containerEl.innerHTML).toEqual('0');
expect(toHtml(containerEl)).toEqual('0');
requestAnimationFrame.flush();
expect(containerEl.innerHTML).toEqual('123');
expect(toHtml(containerEl)).toEqual('123');
component.increment();
markDirty(component, requestAnimationFrame);
expect(containerEl.innerHTML).toEqual('123');
expect(toHtml(containerEl)).toEqual('123');
requestAnimationFrame.flush();
expect(containerEl.innerHTML).toEqual('124');
expect(toHtml(containerEl)).toEqual('124');
});
});