Typescript-TDD / ts-auto-mock

Typescript transformer to unlock automatic mock creation for interfaces and classes

Home Page:https://typescript-tdd.github.io/ts-auto-mock

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hydrated mock with undefined object values as parameter

C0ZEN opened this issue Β· comments

Subject of the issue

I noticed on subtle change between the createMock and createHydratedMock functions.
Following my last comment #699.
Should fix Sonia-corporation/sonia-discord#1383

Your environment

  • ts-auto-mock version: 3.2.1
  • typescript version: 4.2.4
  • node version: 14.17.0
  • npm version: 7.12.1
  • jest-ts-auto-mock: 2.0.0

Steps to reproduce

No problem, the features will stay undefined.

channel = createMock<IFirebaseGuildChannelV2>({
  features: undefined,
  id: `dummy-id`,
  version: FirebaseGuildChannelVersionEnum.V2,
});

The features will have random values.

channel = createHydratedMock<IFirebaseGuildChannelV2>({
  features: undefined,
  id: `dummy-id`,
  version: FirebaseGuildChannelVersionEnum.V2,
});

Expected behaviour

Same behaviour between createMock and createHydratedMock functions which replace the undefined value as expected (so createMock is better IMO).

Actual behaviour

The createHydratedMock function will ignore the given object value if undefined instead of using the value to fill the mock.

this should be easy to solve, I'll take care of this

PR open, just waiting for @uittorio to review it hoping he likes it 🀞

πŸŽ‰ This issue has been resolved in version 3.2.2 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€