Socket
Socket
Sign inDemoInstall

neo-forgery

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

neo-forgery - npm Package Compare versions

Comparing version 1.5.5 to 1.5.6

lib/custom/types/SampleOutputRecord.d.ts

3

lib/custom/records/instanciateRecord.d.ts

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

import { ReturnedDataRecord } from "../types/ReturnedDataRecord";
export declare function instanciateRecord(returnedDataRecord: ReturnedDataRecord): Record<any, any>;
export declare function instanciateRecord(returnedDataRecord: object): Record<any, any>;

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

import { SampleOutputRecord } from "../types/ReturnedDataRecord";
import { SampleOutputRecord } from "../types/SampleOutputRecord";
export declare function instanciateRecordFromSampleOutput(sampleOutputRecord: SampleOutputRecord): Record<any, any>;

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

import { ReturnedDataRecord } from "../types/ReturnedDataRecord";
export declare function instanciateRecordList(returnedDataRecords: ReturnedDataRecord[]): Record<any, any>[];
export declare function instanciateRecordList(returnedDataRecords: object[]): Record<any, any>[];

@@ -1,5 +0,4 @@

import { ReturnedDataRecord } from "../types/ReturnedDataRecord";
export declare function mockResultsFromData(sampleResults: ReturnedDataRecord[]): {
export declare function mockResultsFromData(sampleResults: object[]): {
records: Record<any, any>[];
resultsSummary: {};
};

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

import { SampleOutputRecord } from "./ReturnedDataRecord";
import { SampleOutputRecord } from "./SampleOutputRecord";
export interface MockOutput {

@@ -3,0 +3,0 @@ records: SampleOutputRecord[];

export * from './custom/types/DatabaseInfo';
export * from './custom/types/QuerySpec';
export * from './custom/types/MockOutput';
export * from './custom/types/ReturnedDataRecord';
export * from './custom/types/SampleOutputRecord';
export declare const mockSessionFromQuerySet: any;

@@ -6,0 +6,0 @@ export declare const mockSessionFromFunction: any;

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

tslib_1.__exportStar(require("./custom/types/MockOutput"), exports);
tslib_1.__exportStar(require("./custom/types/ReturnedDataRecord"), exports);
tslib_1.__exportStar(require("./custom/types/SampleOutputRecord"), exports);
exports.mockSessionFromQuerySet = require('./custom/session/mockSessionFromQuerySet');

@@ -16,0 +16,0 @@ exports.mockSessionFromFunction = require('./custom/session/mockSessionFromFunction');

@@ -5,3 +5,3 @@ {

"author": "YizYah",
"version": "1.5.5",
"version": "1.5.6",
"bugs": "https://github.com/YizYah/neo-forgery/issues",

@@ -33,3 +33,3 @@ "engines": {

"test": "ava",
"posttest": "npm run view-coverage && npm run report && npm run lint",
"fulltest": "npm run view-coverage && npm run report && npm run lint",
"prepack": "rm -rf lib && tsc -b",

@@ -36,0 +36,0 @@ "report": "nyc report --reporter=json",

@@ -50,2 +50,4 @@

* [:heavy_exclamation_mark: Limits](#heavy_exclamation_mark-limits)
* [Data Types](#data-types)
* [Functions](#functions)
<!-- tocstop -->

@@ -133,2 +135,4 @@

An alternative to `mockResultsFromCapturedOutput` is `mockResultsFromData`, which takes as input an array of objects containing record values. That can be useful if you know what data you want, and did not copy the Results from the data browser or from a `console.log` statement.
## Checking the Validity of Your Mocked Queries

@@ -161,3 +165,3 @@ The `neo-forgery` package is build based on the premise that unit tests must be fast. By removing the need to query an actual database, you get instant results. But what if your database changes and the queries no longer work?

## Exported Data Types
## Data Types
There are some interfaces that you can import into your TypeScript project.

@@ -197,2 +201,42 @@

## Functions
### Mock Results Generation
There are two functions for generating mock output. These can be used for confirming that output is what you expect it to be.
```
function mockResultsFromCapturedOutput(sampleOutput: MockOutput)
```
You can pass in results from a query as captured by a `console.log` statement, or based on results from the neo4j data browser.
```
mockResultsFromData(sampleResults: object[])
```
You can pass in an array of objects expected and it returns the mock results.
### Mock Session Generation
There are two functions for mock session generations, analogs to the [mock results generation functions above](#mock-results-generation).
```
mockSessionFromQuerySet
```
You pass in a QuerySet and an instance of a neo4j `Session` is returned.
```
mockSessionFromFunction(sessionRunMock: Function)
```
Pass in a Function and a session is generated.
The `sessionRunMock` function shoud take in as parameters (query: string, params: any), and should normally return mock results. You can use the [mock results generation functions above](#mock-results-generation) for the returned values. You can also vary the output from the function based upon the query and params received. In theory you could create a session which emulates your entire database for all of the queries in your tests, and simply reuse the mock session in all of your tests. Note that you can also throw errors if you are testing for them.
### Verification of Your Mock Query Results
One last function is
```
testQuerySet(querySet: QuerySpec[], databaseInfo: DatabaseInfo)
```
See [Checking the Validity of Your Mocked Queries](#checking-the-validity-of-your-mocked-queries) above.
# <a name="heavy_exclamation_mark-limits"></a>:heavy_exclamation_mark: Limits

@@ -199,0 +243,0 @@ 1. This package will not help you to test a section of code where you explicitly declare a session using neo4j-driver. Rather, it helps when you can pass in a session as a parameter.

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