angular-unit-test-helper
Advanced tools
Comparing version 9.1.1 to 9.1.2
@@ -6,2 +6,6 @@ export declare enum ObservablePropertyStrategy { | ||
} | ||
export declare function autoSpyObj(classUnderTest: () => any, spyProperties?: string[], observableStrategy?: ObservablePropertyStrategy): any; | ||
export declare function autoSpyObj({ classUnderTest, spyProperties, observableStrategy, }: { | ||
classUnderTest: NewableFunction; | ||
spyProperties?: string[]; | ||
observableStrategy?: ObservablePropertyStrategy; | ||
}): any; |
{ | ||
"name": "angular-unit-test-helper", | ||
"version": "9.1.1", | ||
"version": "9.1.2", | ||
"description": "Helper functions to help write unit tests in Angular using mocks and spies", | ||
@@ -50,2 +50,3 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@angular/compiler": "^9.0.5", | ||
"@angular/core": "^9.0.5", | ||
@@ -52,0 +53,0 @@ "@istanbuljs/nyc-config-typescript": "^1.0.1", |
@@ -12,7 +12,11 @@ import { BehaviorSubject, Observable } from 'rxjs' | ||
export function autoSpyObj( | ||
classUnderTest: () => any, | ||
spyProperties: string[] = [], | ||
observableStrategy = ObservablePropertyStrategy.Observable | ||
) { | ||
export function autoSpyObj({ | ||
classUnderTest, | ||
spyProperties = [], | ||
observableStrategy = ObservablePropertyStrategy.Observable, | ||
}: { | ||
classUnderTest: NewableFunction | ||
spyProperties?: string[] | ||
observableStrategy?: ObservablePropertyStrategy | ||
}) { | ||
const props = Reflect.ownKeys(classUnderTest.prototype) | ||
@@ -19,0 +23,0 @@ const spyObj = jasmine.createSpyObj( |
@@ -20,6 +20,13 @@ import { Component } from '@angular/core' | ||
const newClass: any = ((window as any)[className] = () => {}) | ||
const newClass: any = (getWindow()[className] = () => {}) | ||
return __decorate([Component({ selector: selectorName, template })], newClass) | ||
} | ||
function getWindow(): any { | ||
if (typeof window === 'undefined') { | ||
return {} | ||
} | ||
return window | ||
} | ||
function inferSelectorName(className: string) { | ||
@@ -26,0 +33,0 @@ className = className.replace('Component', '') |
{ | ||
"compilerOptions": { | ||
"baseUrl": "./", | ||
"moduleResolution": "node", | ||
@@ -15,3 +14,2 @@ "emitDecoratorMetadata": true, | ||
"declaration": true, | ||
"outDir": "./dist", | ||
"sourceMap": true, | ||
@@ -29,4 +27,3 @@ "noImplicitAny": true, | ||
"resolveJsonModule": true | ||
}, | ||
"include": ["./src"] | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
26754
35
432
37