0.0.2 • Published 8 years ago

mockable-container v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

mockable-container

Mockable container has only usage for mock-up. You can try this container at low cost.

Usage

You must instantiate container on your application.

// yourApplication.js 
const Container=require('mockable-contaienr');

const contaienr=new Container();

module.exports = container.getExportModule();

Next, you must registor some component.

// some module.js
const application = require('yourApplication')

class Foo{
  //... some implementation
  test(){
    console.log("foo")
  }
}
// Foo must has name property.
module.exports = application.ClassComponent(Foo);

Next, you can replace module.

const application=require('application');
const Foo = require('module');
new Foo().test(); // foo

// TODO provide smart way
application.contaienr.reference.Foo= () => {
  test:function(){console.log('bar')}
};

new Foo().test(); // bar