Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocking objects with non-function values #48

Open
PEZO19 opened this issue Sep 26, 2020 · 2 comments
Open

Mocking objects with non-function values #48

PEZO19 opened this issue Sep 26, 2020 · 2 comments

Comments

@PEZO19
Copy link

PEZO19 commented Sep 26, 2020

Hi! Is it possible to mock simple objects somehow based on interfaces where the value is not a function?

Instead

interface PartyProvider {
   getPartyType: () => string;
   getSongs: (type: string) => string[];
}

I'd like to mock

interface PartyProvider {
   getPartyType: string;
   getSongs: string[];
}

(and also being able to do that in nested form).

@PEZO19 PEZO19 changed the title Mocking simple objects Mocking objects with non-function values Sep 26, 2020
@anrolmar
Copy link

anrolmar commented Dec 3, 2020

Hi, @PEZO19. I would want to do the same. Any progress?

@Nightbr
Copy link

Nightbr commented Mar 17, 2021

This is working for me, but can't make it work with Date props.

interface MyObj {
   expiredAt: Date;
   test: string;
}

const obj = mock<MyObj>();

obj.expiredtAt = mock<Date>(new Date()); // not working
obj.test = "mockString";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants