2017-01-20 16:10:57 -05:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* 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 {RootRenderer} from '@angular/core';
|
2017-01-26 20:07:37 -05:00
|
|
|
import {checkNodeDynamic, checkNodeInline} from '@angular/core/src/view/index';
|
2017-01-20 16:10:57 -05:00
|
|
|
import {TestBed} from '@angular/core/testing';
|
|
|
|
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
|
|
|
|
|
|
|
export function isBrowser() {
|
|
|
|
return getDOM().supportsDOMEvents();
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setupAndCheckRenderer(config: {directDom: boolean}) {
|
|
|
|
let rootRenderer: any;
|
|
|
|
if (config.directDom) {
|
|
|
|
beforeEach(() => {
|
|
|
|
rootRenderer = <any>{
|
|
|
|
renderComponent: jasmine.createSpy('renderComponent')
|
|
|
|
.and.throwError('Renderer should not have been called!')
|
|
|
|
};
|
|
|
|
TestBed.configureTestingModule(
|
|
|
|
{providers: [{provide: RootRenderer, useValue: rootRenderer}]});
|
|
|
|
});
|
|
|
|
afterEach(() => { expect(rootRenderer.renderComponent).not.toHaveBeenCalled(); });
|
|
|
|
} else {
|
|
|
|
beforeEach(() => {
|
|
|
|
rootRenderer = TestBed.get(RootRenderer);
|
|
|
|
spyOn(rootRenderer, 'renderComponent').and.callThrough();
|
|
|
|
});
|
|
|
|
afterEach(() => { expect(rootRenderer.renderComponent).toHaveBeenCalled(); });
|
|
|
|
}
|
|
|
|
}
|
2017-01-20 12:21:09 -05:00
|
|
|
|
|
|
|
export enum InlineDynamic {
|
|
|
|
Inline,
|
|
|
|
Dynamic
|
|
|
|
}
|
|
|
|
|
|
|
|
export const INLINE_DYNAMIC_VALUES = [InlineDynamic.Inline, InlineDynamic.Dynamic];
|
|
|
|
|
2017-01-26 20:07:37 -05:00
|
|
|
export function checkNodeInlineOrDynamic(inlineDynamic: InlineDynamic, values: any[]): any {
|
2017-01-20 12:21:09 -05:00
|
|
|
switch (inlineDynamic) {
|
|
|
|
case InlineDynamic.Inline:
|
2017-01-26 20:07:37 -05:00
|
|
|
return (<any>checkNodeInline)(...values);
|
2017-01-20 12:21:09 -05:00
|
|
|
case InlineDynamic.Dynamic:
|
2017-01-26 20:07:37 -05:00
|
|
|
return checkNodeDynamic(values);
|
2017-01-20 12:21:09 -05:00
|
|
|
}
|
|
|
|
}
|