chore: fix tests

This commit is contained in:
Roman Hotsiy 2017-03-15 17:51:46 +02:00
parent 631dfc17dc
commit abae4c03c3
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
5 changed files with 22 additions and 12 deletions

View File

@ -4,7 +4,7 @@ import {
Injectable,
ComponentFactory,
ComponentRef,
ViewContainerRef,
ViewContainerRef
} from '@angular/core';
@Injectable()
@ -19,7 +19,6 @@ export class ContentProjector {
for (let i=0; i < projectedNodesOrComponents.length; i++) {
let nodeOrCompRef = projectedNodesOrComponents[i];
if (nodeOrCompRef instanceof ComponentRef) {
//nodeOrCompRef.changeDetectorRef.detectChanges();
projectedNodes.push(nodeOrCompRef.location.nativeElement);
componentRefs.push(nodeOrCompRef);
} else {
@ -29,13 +28,13 @@ export class ContentProjector {
let parentCompRef = parentView.createComponent(componentFactory, null, contextInjector, [projectedNodes]);
// using private property to get AppElement instance
// using private property to get view instance
let viewContainer = (<any>parentView)._view;
let viewData = (<any>parentView)._data;
viewData.embeddedViews = viewData.embeddedViews || [];
for (let i=0; i < componentRefs.length; i++) {
let compRef = componentRefs[i];
// attach view to viewContainer change detector
// attach view to containter change detector
viewData.embeddedViews.push((<any>compRef.hostView)._view);
(<any>compRef.hostView).attachToViewContainerRef(viewContainer);
}

View File

@ -1,7 +1,6 @@
'use strict';
import { By } from '@angular/platform-browser';
import { getDOM } from '@angular/platform-browser/src/dom/dom_adapter';
/** Gets a child DebugElement by tag name. */
export function getChildDebugElement(parent, tagName) {
@ -20,7 +19,13 @@ export function getChildDebugElementAll(parent, tagName) {
export function mouseclick( element ) {
// create a mouse click event
var dispatchedEvent = getDOM().createMouseEvent('click');
var dispatchedEvent
try {
dispatchedEvent = new MouseEvent('click', true);
} catch (e) {
dispatchedEvent = document.createEvent('MouseEvent');
dispatchedEvent.initEvent('click', true, false);
}
// send click to element
getDOM().dispatchEvent(element, dispatchedEvent);
element.dispatchEvent(dispatchedEvent);
}

View File

@ -20,9 +20,10 @@ require('../lib/vendor');
var TestBed = require('@angular/core/testing').TestBed;
var ErrorHandler = require('@angular/core').ErrorHandler;
var forwardRef = require('@angular/core').forwardRef;
var BrowserDynamicTestingModule = require('@angular/platform-browser-dynamic/testing').BrowserDynamicTestingModule;
var platformBrowserDynamicTesting = require('@angular/platform-browser-dynamic/testing').platformBrowserDynamicTesting;
var BrowserAnimationsModule = require('@angular/platform-browser/animations').BrowserAnimationsModule;
var SpecManager = require('../lib/utils/spec-manager').SpecManager;
var services = require('../lib/services/index');
var REDOC_PIPES = require('../lib/utils/pipes').REDOC_PIPES;
@ -38,6 +39,7 @@ TestBed.initTestEnvironment(
beforeEach(function() {
TestBed.configureTestingModule({
imports: [BrowserAnimationsModule],
providers: [
SpecManager,
services.AppStateService,
@ -51,7 +53,7 @@ beforeEach(function() {
services.Marker,
services.SearchService,
{ provide: sharedComponents.LazyTasksService, useClass: sharedComponents.LazyTasksServiceSync },
{ provide: ErrorHandler, useClass: services.CustomErrorHandler },
//{ provide: ErrorHandler, useClass: forwardRef(function() {return services.CustomErrorHandler}) },
{ provide: services.COMPONENT_PARSER_ALLOWED, useValue: { 'security-definitions': components.SecurityDefinitions }}
],
declarations: [REDOC_PIPES, REDOC_DIRECTIVES, REDOC_COMMON_DIRECTIVES]

View File

@ -9,10 +9,12 @@
"pretty": true,
"moduleResolution": "node",
"types": [
"core-js",
"jasmine",
"should",
"requirejs"
"webpack"
],
"lib": [
"DOM", "ES2016", "DOM.Iterable"
],
"noEmitHelpers": true
},

View File

@ -1,4 +1,7 @@
{
"linterOptions": {
"typeCheck": true
},
"rulesDirectory": ["node_modules/codelyzer"],
"rules": {
"class-name": true,
@ -42,7 +45,6 @@
"no-input-rename": true,
"no-output-rename": true,
"pipe-naming": [true, "camelCase"],
"import-destructuring-spacing": true,
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"templates-use-public": true,