Ellisande / mockolate

Simple mocking framework for JS
MIT License
1 stars 3 forks source link

Mock Objects #3

Open Ellisande opened 8 years ago

Ellisande commented 8 years ago

What kind of issue is this? (bug, feature, etc)

Feature

What is the proposed change?

Add a simple method for turning a real object into a mocked object.

Why will this be beneficial?

This will allow people to easily stub out external dependencies.

Misc. info

The thought is it would work something like this:

var ninja = {
  power: 1,
  name: 'Ryu',
  getArsenal: () => {},
  killBadGuys: () => {}
}

var mockedNinja = mock(ninja);
// mockedNinja.power === 1;
// mockedNinja.name === 'Ryu';
// mockedNinja.getArsenal => replaced with a mockFunction
// mockedNinja.killBadGuys => replaced with a mockFunction