angular-unit-test-helper
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -1,1 +0,1 @@ | ||
export declare function createComponentMock(className: string, selectorName?: string): any; | ||
export declare function createComponentMock(className: string, selectorName?: string, template?: string): any; |
import { Component } from '@angular/core'; | ||
import camelToKebabCase from 'camel-to-kebab'; | ||
import { __decorate } from 'tslib'; | ||
export function createComponentMock(className, selectorName) { | ||
export function createComponentMock(className, selectorName, template) { | ||
if (template === void 0) { template = ''; } | ||
if (!className || !className.endsWith('Component')) { | ||
@@ -12,3 +13,3 @@ throw 'Expected class name to end with Component, but it did not. Provide a valid component class name.'; | ||
var newClass = (window[className] = function () { }); | ||
return __decorate([Component({ selector: 'app-current-weather', template: '' })], newClass); | ||
return __decorate([Component({ selector: selectorName, template: template })], newClass); | ||
} | ||
@@ -15,0 +16,0 @@ function inferSelectorName(className) { |
@@ -5,3 +5,7 @@ import { Component } from '@angular/core' | ||
export function createComponentMock(className: string, selectorName?: string) { | ||
export function createComponentMock( | ||
className: string, | ||
selectorName?: string, | ||
template = '' | ||
) { | ||
if (!className || !className.endsWith('Component')) { | ||
@@ -16,6 +20,3 @@ throw 'Expected class name to end with Component, but it did not. Provide a valid component class name.' | ||
const newClass: any = ((window as any)[className] = () => {}) | ||
return __decorate( | ||
[Component({ selector: 'app-current-weather', template: '' })], | ||
newClass | ||
) | ||
return __decorate([Component({ selector: selectorName, template: template })], newClass) | ||
} | ||
@@ -22,0 +23,0 @@ |
{ | ||
"name": "angular-unit-test-helper", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "Helper functions to help write unit tests in Angular using mocks and spies", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -41,3 +41,3 @@ # Angular Unit Test Helper | ||
### createComponentMock(className: string, selectorName?: string) | ||
### createComponentMock(className: string, selectorName?: string, template = '') | ||
@@ -55,2 +55,4 @@ Creates a mock class decorated with @Component, if not specified selector is inferred to be MyClassComponent -> app. | ||
Option to override empty template. | ||
Usage | ||
@@ -57,0 +59,0 @@ ``` |
Sorry, the diff of this file is not supported yet
13636
179
63