diff --git a/package-lock.json b/package-lock.json index df14ffc..c8127b4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "frlluc-mocking", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 152f11b..268cee1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/core/mock.interface.ts b/src/core/mock.interface.ts index b86a59e..97235da 100644 --- a/src/core/mock.interface.ts +++ b/src/core/mock.interface.ts @@ -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 { @@ -12,5 +13,5 @@ export interface IMock { * @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; } diff --git a/src/core/mock.ts b/src/core/mock.ts index 218551a..18498c2 100644 --- a/src/core/mock.ts +++ b/src/core/mock.ts @@ -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; @@ -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 { return data[no] || null; }, clear(): void { @@ -98,7 +98,7 @@ export function partialMock(subject: T, setup: Partial): IMock { const members = new Set(); const invocationCache: { [id: string]: IMockedMethodInfo | IMockedPropertyInfo } = {}; const result: any = { - getMemberInfo(m: string): IMockedMethodInfo | IMockedPropertyInfo | null { + getMemberInfo(m: string): Nullable { return invocationCache[m] || null; } }; diff --git a/src/core/mocked-method-info.interface.ts b/src/core/mocked-method-info.interface.ts index e58bf10..011a59c 100644 --- a/src/core/mocked-method-info.interface.ts +++ b/src/core/mocked-method-info.interface.ts @@ -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 { @@ -12,7 +13,7 @@ export interface IMockedMethodInfo { * @param invocationNo invocation's index * @returns invocation data * */ - getData(invocationNo: number): IInvocationData | null; + getData(invocationNo: number): Nullable; /** Clears all stored invocation data. */ clear(): void; } diff --git a/src/core/mocked-property-info.interface.ts b/src/core/mocked-property-info.interface.ts index d2d7b81..6f24ce8 100644 --- a/src/core/mocked-property-info.interface.ts +++ b/src/core/mocked-property-info.interface.ts @@ -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; /** Specifies property's mocked setter information store. */ - readonly set: IMockedMethodInfo | null; + readonly set: Nullable; }