🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

shallow-render

Package Overview
Dependencies
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shallow-render - npm Package Compare versions

Comparing version

to
16.0.0

2

dist/lib/models/angular-module.d.ts
import { ModuleWithProviders, Type } from '@angular/core';
export declare type AngularModule = Type<any> | ModuleWithProviders<any>;
export type AngularModule = Type<any> | ModuleWithProviders<any>;

@@ -35,3 +35,3 @@ import { CustomError } from './custom-error';

*/
export declare type QueryMatch<TMatch> = TMatch[] & TMatch;
export type QueryMatch<TMatch> = TMatch[] & TMatch;
export declare class NoMatchesError extends CustomError {

@@ -38,0 +38,0 @@ constructor(propertyName: string);

@@ -5,4 +5,4 @@ /**

*/
export declare type RecursivePartial<T> = Partial<{
export type RecursivePartial<T> = Partial<{
[key in keyof T]: T[key] extends (...a: Array<infer U>) => any ? (...a: Array<U>) => RecursivePartial<ReturnType<T[key]>> | ReturnType<T[key]> : T[key] extends Array<any> ? Array<RecursivePartial<T[key][number]>> : RecursivePartial<T[key]> | T[key];
}>;

@@ -26,13 +26,2 @@ "use strict";

class Shallow {
constructor(testComponentOrService, testModule) {
this.setup = new test_setup_1.TestSetup(testComponentOrService, testModule);
this.setup.dontMock.push(...Shallow._neverMock);
this.setup.providers.unshift(...Shallow._alwaysProvide);
this.setup.imports.push(...Shallow._alwaysImport);
this.setup.alwaysRenderStructuralDirectives = Shallow._alwaysRenderStructuralDirectives;
Shallow._alwaysMock.forEach((value, key) => this.setup.mocks.set(key, value));
Shallow._alwaysMockPipes.forEach((value, key) => this.setup.mockPipes.set(key, value));
Shallow._alwaysReplaceModule.forEach((value, key) => this.setup.moduleReplacements.set(key, value));
Shallow._alwaysWithStructuralDirectives.forEach((value, key) => this.setup.withStructuralDirectives.set(key, value));
}
/**

@@ -165,2 +154,13 @@ * Instruct *all* shallow-render tests to prevent mocking of a particular:

}
constructor(testComponentOrService, testModule) {
this.setup = new test_setup_1.TestSetup(testComponentOrService, testModule);
this.setup.dontMock.push(...Shallow._neverMock);
this.setup.providers.unshift(...Shallow._alwaysProvide);
this.setup.imports.push(...Shallow._alwaysImport);
this.setup.alwaysRenderStructuralDirectives = Shallow._alwaysRenderStructuralDirectives;
Shallow._alwaysMock.forEach((value, key) => this.setup.mocks.set(key, value));
Shallow._alwaysMockPipes.forEach((value, key) => this.setup.mockPipes.set(key, value));
Shallow._alwaysReplaceModule.forEach((value, key) => this.setup.moduleReplacements.set(key, value));
Shallow._alwaysWithStructuralDirectives.forEach((value, key) => this.setup.withStructuralDirectives.set(key, value));
}
/**

@@ -167,0 +167,0 @@ * Enforce the default render state of a given directive's contents.

@@ -8,2 +8,2 @@ export interface TestFramework {

}
export declare type AnyFunction = (...args: any[]) => any;
export type AnyFunction = (...args: any[]) => any;

@@ -28,6 +28,2 @@ "use strict";

const declarations = (0, ng_mock_1.ngMock)([...ngModule.declarations, ...setup.declarations].filter(d => d !== setup.testComponentOrService), setup);
// Test Modules cannot directly define entryComponents. To work around this,
// we create a new module which declares/exports all entryComponents and import
// the module into the TestModule.
const entryComponents = [...(0, ng_mock_1.ngMock)([...ngModule.entryComponents], setup), ...setup.declarations];
let ShallowTestModule = class ShallowTestModule {

@@ -39,5 +35,4 @@ };

declarations: [...declarations, ...testComponents],
entryComponents,
providers: (0, mock_provider_1.mockProvider)([...setup.providers, ...ngModule.providers, ...additionalProviders], setup),
exports: [...declarations, ...entryComponents],
exports: declarations,
schemas: ngModule.schemas || [],

@@ -44,0 +39,0 @@ })

@@ -8,5 +8,4 @@ import { EnvironmentProviders, NgModule, Provider, SchemaMetadata, Type } from '@angular/core';

exports: (Type<any> | any[])[];
entryComponents: (any[] | Type<any>)[];
schemas: SchemaMetadata[] | any[];
}
export declare function getNgModuleAnnotations(ngModule: Type<any>): NgModuleAnnotations;

@@ -6,6 +6,6 @@ "use strict";

function getNgModuleAnnotations(ngModule) {
const { imports = [], providers = [], declarations = [], exports = [], entryComponents = [], schemas = [], } = reflect_1.reflect.resolveModule(ngModule) || {};
return { imports, providers, declarations, exports, entryComponents, schemas };
const { imports = [], providers = [], declarations = [], exports = [], schemas = [], } = reflect_1.reflect.resolveModule(ngModule) || {};
return { imports, providers, declarations, exports, schemas };
}
exports.getNgModuleAnnotations = getNgModuleAnnotations;
//# sourceMappingURL=get-ng-module-annotations.js.map
import { Type } from '@angular/core';
export declare type MockDirective = {
export type MockDirective = {
renderContents: () => void;

@@ -4,0 +4,0 @@ clearContents: () => void;

@@ -7,3 +7,3 @@ import { AngularModule } from '../models/angular-module';

}
export declare type AnyNgModule = any[] | AngularModule;
export type AnyNgModule = any[] | AngularModule;
export declare function mockModule<TModule extends AnyNgModule>(mod: TModule, setup: TestSetup<any>): TModule;

@@ -55,3 +55,3 @@ "use strict";

const modClass = mod;
const { imports, declarations, exports, entryComponents, providers, schemas } = (0, get_ng_module_annotations_1.getNgModuleAnnotations)(modClass);
const { imports, declarations, exports, providers, schemas } = (0, get_ng_module_annotations_1.getNgModuleAnnotations)(modClass);
const mockedModule = {

@@ -61,3 +61,2 @@ imports: (0, ng_mock_1.ngMock)(imports, setup),

exports: collapseModuleWithProviders((0, ng_mock_1.ngMock)(exports, setup)),
entryComponents: (0, ng_mock_1.ngMock)(entryComponents, setup),
providers: providers.map(p => (0, mock_provider_1.mockProvider)(p, setup)),

@@ -64,0 +63,0 @@ schemas,

import { PipeTransform, Type } from '@angular/core';
import { AngularModule } from '../models/angular-module';
import { TestSetup } from '../models/test-setup';
export declare type NgMockable = AngularModule | Type<any> | Type<PipeTransform> | any[];
export type NgMockable = AngularModule | Type<any> | Type<PipeTransform> | any[];
export declare function ngMock<TThing extends NgMockable | NgMockable[]>(thing: TThing, setup: TestSetup<any>): TThing;
import { EventEmitter } from '@angular/core';
import { CustomError } from '../models/custom-error';
export declare type KeysOfType<TObject, TPropertyType> = {
export type KeysOfType<TObject, TPropertyType> = {
[K in keyof TObject]: TObject[K] extends TPropertyType ? K : never;
}[keyof TObject];
export declare type PickByType<TObject, TPropertyType> = Pick<TObject, KeysOfType<TObject, TPropertyType>>;
export type PickByType<TObject, TPropertyType> = Pick<TObject, KeysOfType<TObject, TPropertyType>>;
export declare class PropertyNotMarkedAsOutputError extends CustomError {

@@ -8,0 +8,0 @@ constructor(key: string | symbol | number, component: any);

import { Component, Directive, NgModule, Pipe, PipeTransform } from '@angular/core';
declare type IODefinition = {
type IODefinition = {
propertyName: string;
alias: string;
};
declare type InputsAndOutputs = {
type InputsAndOutputs = {
inputs: IODefinition[];

@@ -8,0 +8,0 @@ outputs: IODefinition[];

@@ -33,3 +33,4 @@ "use strict";

var _a;
return (Object.assign(Object.assign({}, acc), (_a = metadata[key]) === null || _a === void 0 ? void 0 : _a.reduce((acc2, name) => (Object.assign(Object.assign({}, acc2), { [name]: [{ type }] })), {})));
const normalized = (_a = metadata[key]) === null || _a === void 0 ? void 0 : _a.map(a => (typeof a === 'string' ? { name: a } : a));
return Object.assign(Object.assign({}, acc), normalized === null || normalized === void 0 ? void 0 : normalized.reduce((acc2, i) => (Object.assign(Object.assign({}, acc2), { [i.name]: [{ type }] })), {}));
}, {});

@@ -36,0 +37,0 @@ };

import { ClassProvider, ExistingProvider, FactoryProvider, ModuleWithProviders, PipeTransform, Provider, TypeProvider, ValueProvider, Type, EnvironmentProviders } from '@angular/core';
export declare function isModuleWithProviders(thing: any): thing is ModuleWithProviders<any>;
export declare function isModuleWithProviders(thing: unknown): thing is ModuleWithProviders<any>;
export declare function isValueProvider(provider: Provider): provider is ValueProvider;

@@ -8,4 +8,4 @@ export declare function isExistingProvider(provider: Provider): provider is ExistingProvider;

export declare function isTypeProvider(provider: Provider): provider is TypeProvider;
export declare function isPipeTransform(thing: any): thing is PipeTransform & Type<any>;
export declare const isClass: (thing: any) => thing is Type<any>;
export declare function isPipeTransform(thing: unknown): thing is PipeTransform & Type<any>;
export declare const isClass: (thing: unknown) => thing is Type<any>;
/**

@@ -12,0 +12,0 @@ * Angular explicitly obscured the EnvironmentProviders type that require hard-casting to unbox

@@ -8,3 +8,3 @@ "use strict";

const key = 'ngModule';
return typeof thing === 'object' && key in thing;
return !!thing && typeof thing === 'object' && key in thing;
}

@@ -11,0 +11,0 @@ exports.isModuleWithProviders = isModuleWithProviders;

{
"name": "shallow-render",
"version": "15.0.3",
"version": "16.0.0",
"description": "Shallow rendering test utility for Angular",

@@ -52,32 +52,32 @@ "main": "dist/index.js",

"peerDependencies": {
"@angular/common": "15.x",
"@angular/compiler": "15.x",
"@angular/core": "15.x",
"@angular/forms": "15.x",
"@angular/platform-browser": "15.x"
"@angular/common": "16.x",
"@angular/compiler": "16.x",
"@angular/core": "16.x",
"@angular/forms": "16.x",
"@angular/platform-browser": "16.x"
},
"devDependencies": {
"@angular-devkit/build-angular": "^15.0.4",
"@angular-eslint/eslint-plugin": "^14.0.2",
"@angular-eslint/eslint-plugin-template": "^14.0.2",
"@angular/common": "^15.0.0",
"@angular/compiler": "^15.0.0",
"@angular/compiler-cli": "^15.0.0",
"@angular/core": "^15.0.0",
"@angular/forms": "^15.0.0",
"@angular/platform-browser": "^15.0.0",
"@angular/platform-browser-dynamic": "^15.0.0",
"@angular/router": "^15.0.0",
"@types/jest": "^28.1.6",
"@typescript-eslint/eslint-plugin": "^5.8.0",
"@typescript-eslint/parser": "^5.8.0",
"eslint": "^8.5.0",
"jest": "^28.1.3",
"jest-preset-angular": "^12.2.0",
"prettier": "^2.0.5",
"rxjs": "~7.5.0",
"ts-node": "^10.4.0",
"typescript": "~4.8.2",
"zone.js": "~0.12.0"
"@angular-devkit/build-angular": "^16.1.5",
"@angular-eslint/eslint-plugin": "^16.1.0",
"@angular-eslint/eslint-plugin-template": "^16.1.0",
"@angular/common": "^16.1.0",
"@angular/compiler": "^16.1.0",
"@angular/compiler-cli": "^16.1.0",
"@angular/core": "^16.1.0",
"@angular/forms": "^16.1.0",
"@angular/platform-browser": "^16.1.0",
"@angular/platform-browser-dynamic": "^16.1.0",
"@angular/router": "^16.1.0",
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"eslint": "^8.45.0",
"jest": "^29.6.1",
"jest-preset-angular": "^13.1.1",
"prettier": "^3.0.0",
"rxjs": "~7.8.0",
"ts-node": "^10.9.1",
"typescript": "~5.1.3",
"zone.js": "~0.13.0"
}
}
# shallow-render
[![Build Status](https://travis-ci.org/getsaf/shallow-render.svg?branch=master)](https://travis-ci.org/getsaf/shallow-render)
[![CircleCI](https://circleci.com/gh/getsaf/shallow-render.svg?style=svg)](https://circleci.com/gh/getsaf/shallow-render)
[![npm version](https://badge.fury.io/js/shallow-render.svg)](https://www.npmjs.com/package/shallow-render)

@@ -5,0 +5,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet