New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular-unit-test-helper

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-unit-test-helper - npm Package Compare versions

Comparing version 13.0.2 to 13.0.3

2

dist/createComponentMock.d.ts

@@ -1,1 +0,1 @@

export declare function createComponentMock(className: string, selectorName?: string, template?: string): any;
export declare function createComponentMock(className: string, selectorName?: string, template?: string): void;

@@ -1,30 +0,8 @@

import { Component } from '@angular/core';
import camelToKebabCase from 'camel-to-kebab';
import { __decorate } from 'tslib';
export function createComponentMock(className, selectorName, template = '') {
if (!className || !className.endsWith('Component')) {
throw new Error('Expected class name to end with Component, but it did not. Provide a valid component class name.');
}
if (!selectorName) {
selectorName = inferSelectorName(className);
}
const newClass = (getWindow()[className] = () => { });
const decoratedObject = __decorate([Component({ selector: selectorName, template })], newClass);
if (!decoratedObject.prototype) {
decoratedObject.prototype = {};
}
return decoratedObject;
className.padStart(0);
selectorName === null || selectorName === void 0 ? void 0 : selectorName.padStart(0);
template.padStart(0);
console.error('createComponentMock has been removed. Use ng-mocks instead. See README.md for more information.');
throw new Error('createComponentMock has been removed.');
}
function getWindow() {
if (typeof window === 'undefined') {
return {};
}
/* istanbul ignore next */
return window;
}
function inferSelectorName(className) {
className = className.replace('Component', '');
className = camelToKebabCase(className);
return `app-${className}`;
}
//# sourceMappingURL=createComponentMock.js.map
{
"name": "angular-unit-test-helper",
"version": "13.0.2",
"version": "13.0.3",
"description": "Helper functions to help write unit tests in Angular using mocks and spies",

@@ -73,6 +73,3 @@ "main": "dist/index.js",

"typescript": "^4"
},
"dependencies": {
"camel-to-kebab": "^1.1.2"
}
}

@@ -29,2 +29,3 @@ # Angular Unit Test Helper

Check out my sample projects that leverage `angular-unit-test-helper`:
- https://github.com/duluca/local-weather-app

@@ -109,4 +110,21 @@ - https://github.com/duluca/lemon-mart

### `createComponentMock(className: string, selectorName?: string, template = '')`
### _deprecated_ `createComponentMock(className: string, selectorName?: string, template = '')`
_Deprecated_ Use `ng-mocks` instead. https://ng-mocks.sudo.eu/api/MockComponent.
1. Install using `install i -D ng-mocks`
2. Refactor `createComponentMock` function calls to look like the sample below:
```TypeScript
TestBed.configureTestingModule({
declarations: [
// for a single component
MockComponent(Component),
// for a set of components
...MockComponents(Component1, Component2),
],
})
```
Creates a mock class decorated with @Component, if not specified selector is inferred to be MyClassComponent -> app. Provides an option to override empty template.

@@ -113,0 +131,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc