Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
CalionVarduk committed Jun 1, 2019
2 parents 82d756e + be4191b commit 8aa263f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frlluc-mocking",
"version": "1.0.3",
"version": "1.0.4",
"description": "A simple mocking framework targetting TypeScript",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/core/mock.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { IMockedMethodInfo } from './mocked-method-info.interface';
import { IMockedPropertyInfo } from './mocked-property-info.interface';
import { Nullable } from 'frlluc-utils';

/** Represents a mock proxy. */
export interface IMock<T> {
Expand All @@ -12,5 +13,5 @@ export interface IMock<T> {
* @param memberName subject's member name
* @returns mocked method or property information store
* */
getMemberInfo(memberName: keyof T): IMockedMethodInfo | IMockedPropertyInfo | null;
getMemberInfo(memberName: keyof T): Nullable<IMockedMethodInfo | IMockedPropertyInfo>;
}
6 changes: 3 additions & 3 deletions src/core/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IMockedMethodInfo } from './mocked-method-info.interface';
import { IMockedPropertyInfo } from './mocked-property-info.interface';
import { IInvocationData } from './invocation-data.interface';
import { IMock } from './mock.interface';
import { reinterpretCast } from 'frlluc-utils';
import { reinterpretCast, Nullable } from 'frlluc-utils';

let GLOBAL_INVOCATION_NO = 0;

Expand All @@ -13,7 +13,7 @@ function createMethodInfo(type: MockedInfoType, data: IInvocationData[]): IMocke
get count(): number {
return data.length;
},
getData(no: number): IInvocationData | null {
getData(no: number): Nullable<IInvocationData> {
return data[no] || null;
},
clear(): void {
Expand Down Expand Up @@ -98,7 +98,7 @@ export function partialMock<T>(subject: T, setup: Partial<T>): IMock<T> {
const members = new Set<string>();
const invocationCache: { [id: string]: IMockedMethodInfo | IMockedPropertyInfo } = {};
const result: any = {
getMemberInfo(m: string): IMockedMethodInfo | IMockedPropertyInfo | null {
getMemberInfo(m: string): Nullable<IMockedMethodInfo | IMockedPropertyInfo> {
return invocationCache[m] || null;
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/core/mocked-method-info.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { MockedInfoType } from './mocked-info-type.enum';
import { IInvocationData } from './invocation-data.interface';
import { Nullable } from 'frlluc-utils';

/** Stores mocked method information. */
export interface IMockedMethodInfo {
Expand All @@ -12,7 +13,7 @@ export interface IMockedMethodInfo {
* @param invocationNo invocation's index
* @returns invocation data
* */
getData(invocationNo: number): IInvocationData | null;
getData(invocationNo: number): Nullable<IInvocationData>;
/** Clears all stored invocation data. */
clear(): void;
}
5 changes: 3 additions & 2 deletions src/core/mocked-property-info.interface.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { MockedInfoType } from './mocked-info-type.enum';
import { IMockedMethodInfo } from './mocked-method-info.interface';
import { Nullable } from 'frlluc-utils';

/** Stores mocked property information. */
export interface IMockedPropertyInfo {
/** Specifies mocked info type. */
readonly type: MockedInfoType;
/** Specifies property's mocked getter information store. */
readonly get: IMockedMethodInfo | null;
readonly get: Nullable<IMockedMethodInfo>;
/** Specifies property's mocked setter information store. */
readonly set: IMockedMethodInfo | null;
readonly set: Nullable<IMockedMethodInfo>;
}

0 comments on commit 8aa263f

Please sign in to comment.