Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Latest commit

 

History

History
434 lines (246 loc) · 12.6 KB

File metadata and controls

434 lines (246 loc) · 12.6 KB

andculturecode-javascript-testing

andculturecode-javascript-testing

Index

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

AxiosJestMock

Ƭ AxiosJestMock: Mock‹Promise‹object›, []›

Defined in src/mocks/mock-axios.ts:14

MockAxios is merely a typed wrapper around the dynamically mocked mocks/axios implementation.

Variables

Const AxiosResponseFactory

AxiosResponseFactory: IFactory‹AxiosResponse‹any, any›› = Factory.define( FactoryType.AxiosResponse ) .sequence("status", () => 200) .sequence("statusText", () => "OK")

Defined in src/factories/axios-response-factory.ts:9


Const StubResourceRecordFactory

StubResourceRecordFactory: IFactory‹StubResourceRecord‹›› = Factory.define( FactoryType.StubResourceRecord, StubResourceRecord ) .sequence("id", (i: number) => i) .sequence("name", (i: number) => Name ${i})

Defined in src/factories/stub-resource-record-factory.ts:9

Functions

Const _mockSuccess

_mockSuccess(method: AxiosJestMock, resultObject: any | any[], delay?: undefined | number): void

Defined in src/mocks/mock-axios.ts:88

Parameters:

Name Type
method AxiosJestMock
resultObject any | any[]
delay? undefined | number

Returns: void


Const _resultObjectToJS

_resultObjectToJS(resultObject: any | any[]): any | any[]

Defined in src/mocks/mock-axios.ts:113

Parameters:

Name Type
resultObject any | any[]

Returns: any | any[]


Const deleteSuccess

deleteSuccess(record?: any, delay?: undefined | number): void

Defined in src/mocks/mock-axios.ts:67

Parameters:

Name Type
record? any
delay? undefined | number

Returns: void


Const getSuccess

getSuccess(record: any, delay?: undefined | number): void

Defined in src/mocks/mock-axios.ts:70

Parameters:

Name Type
record any
delay? undefined | number

Returns: void


Const listSuccess

listSuccess(records: any[], delay?: undefined | number): void

Defined in src/mocks/mock-axios.ts:73

Parameters:

Name Type
records any[]
delay? undefined | number

Returns: void


Const postSuccess

postSuccess(record: any, delay?: undefined | number): void

Defined in src/mocks/mock-axios.ts:76

Parameters:

Name Type
record any
delay? undefined | number

Returns: void


Const putSuccess

putSuccess(record: any, delay?: undefined | number): void

Defined in src/mocks/mock-axios.ts:79

Parameters:

Name Type
record any
delay? undefined | number

Returns: void


Const testLoop

testLoop(name: string, fn: Function, times: number): void

Defined in src/utilities/shared-specs.ts:14

Utility function for running a test body a certain number of times. Useful for ensuring specific behavior on implementations that return randomized data and edge cases will not immediately be exposed.

Parameters:

Name Type Default Description
name string - Name of the test
fn Function - Function body to run (can be asynchronous)
times number 100 -

Returns: void

Object literals

Const FactoryType

FactoryType: object

Defined in src/factories/factory-type.ts:1

AxiosResponse

AxiosResponse: string = "AxiosResponse"

Defined in src/factories/factory-type.ts:2

StubResourceRecord

StubResourceRecord: string = "StubResourceRecord"

Defined in src/factories/factory-type.ts:3


Const MockAxios

MockAxios: object

Defined in src/mocks/mock-axios.ts:135

delete

delete: Mock‹Promise‹object›, []› = axios.delete as AxiosJestMock

Defined in src/mocks/mock-axios.ts:136

deleteSuccess

deleteSuccess: deleteSuccess

Defined in src/mocks/mock-axios.ts:137

get

get: Mock‹Promise‹object›, []› = axios.get as AxiosJestMock

Defined in src/mocks/mock-axios.ts:138

getSuccess

getSuccess: getSuccess

Defined in src/mocks/mock-axios.ts:139

listSuccess

listSuccess: listSuccess

Defined in src/mocks/mock-axios.ts:140

post

post: Mock‹Promise‹object›, []› = axios.post as AxiosJestMock

Defined in src/mocks/mock-axios.ts:141

postSuccess

postSuccess: postSuccess

Defined in src/mocks/mock-axios.ts:142

put

put: Mock‹Promise‹object›, []› = axios.put as AxiosJestMock

Defined in src/mocks/mock-axios.ts:143

putSuccess

putSuccess: putSuccess

Defined in src/mocks/mock-axios.ts:144


Const TestUtils

TestUtils: object

Defined in src/utilities/test-utils.ts:3

faker

faker: Faker‹›

Defined in src/utilities/test-utils.ts:8

randomCase

randomCase(value: string): string

Defined in src/utilities/test-utils.ts:19

Randomize case of string

Parameters:

Name Type
value string

Returns: string

randomFilename

randomFilename(): string

Defined in src/utilities/test-utils.ts:33

Wrapper around faker.system.fileName

Returns: string

randomGuid

randomGuid(): string

Defined in src/utilities/test-utils.ts:40

Wrapper around faker.datatype.uuid

Returns: string

randomKey

randomKey(obj: object): string

Defined in src/utilities/test-utils.ts:47

Returns a random key from the given object. If the object has no keys, it returns undefined.

Parameters:

Name Type
obj object

Returns: string

randomObject

randomObject(keyCount?: undefined | number): Record‹string, string›

Defined in src/utilities/test-utils.ts:54

Generates random object

Parameters:

Name Type
keyCount? undefined | number

Returns: Record‹string, string›

randomPath

randomPath(): string

Defined in src/utilities/test-utils.ts:68

Generates random path

Returns: string

randomValue

randomValueTValue›(obj: Record‹string, TValue› | Array‹TValue›): TValue

Defined in src/utilities/test-utils.ts:75

Returns a random value from the given object. If the object has no keys, it returns undefined.

Type parameters:

TValue

Parameters:

Name Type
obj Record‹string, TValue› | Array‹TValue›

Returns: TValue

randomWord

randomWord(): string

Defined in src/utilities/test-utils.ts:91

Wrapper of faker.random.word.

Unfortunately there is an unresolved bug https://github.com/Marak/faker.js/issues/661 and it will occasionally return multiple which can cause test flake

Returns: string

randomWords

randomWords(): string[]

Defined in src/utilities/test-utils.ts:101

Returns a string array of at least two random words, leveraging the TestUtils.randomWord function

Returns: string[]