electrolyte icon indicating copy to clipboard operation
electrolyte copied to clipboard

Add tests to example project

Open saverchenkov opened this issue 10 years ago • 12 comments

I am trying to find a typical pattern of mocking dependencies using electrolyte. Some example tests would be helpful. Thank you!

saverchenkov avatar Feb 17 '15 01:02 saverchenkov

I'll take a pull request for this, but writing extensive example code is not a priority for me personally.

jaredhanson avatar Feb 17 '15 02:02 jaredhanson

+1 to this feature. API method to replace a single module in container would be enough.

mikalai-sauchanka avatar Feb 19 '15 08:02 mikalai-sauchanka

+1 to this feature

digitalwm avatar Feb 20 '15 08:02 digitalwm

+1

joeltello avatar Feb 23 '15 22:02 joeltello

+1

I've created a RequireBin for my solution: http://requirebin.com/?gist=5f1c8f5855a69aa3edc0 .

It's not pretty but it works well for isolated example. In live project though it needed to execute _loadModule method after replacing the dependency.

I would love to see some method to replace method in container. Also, it would be nice to have a section on the topic in readme.

pwlmaciejewski avatar Mar 04 '15 14:03 pwlmaciejewski

+1

charlires avatar Mar 13 '15 06:03 charlires

hey, created a pull request (https://github.com/jaredhanson/electrolyte/pull/16) for a simple mocking extension to the Container class

usage:

ioc.mock( 'real/component', 'mock/component' );

gimre avatar Mar 24 '15 09:03 gimre

+1 on this. My tests looks like:

var ioc = require('electrolyte');
var
  common = ioc.create('commonfuncts'),
  config = ioc.create('config')
  app = ioc.create('app');

// actual test code
common.testMyApp(app, config);

There are ways to shorten this boilerplate?

colthreepv avatar Apr 11 '15 14:04 colthreepv

+1

cades avatar Apr 28 '15 16:04 cades

@jaredhanson you suggest that a PR will be accepted. As one exists, is there an ETA on when it will be merged?

mattgi avatar Jun 09 '15 01:06 mattgi

@jaredhasnon, has there been any progress on this? Given that simplicity of testing is one of the main benefits of IoC-enabled applications, I'd expect that'd be one of the first examples on the page.

dkushner avatar Jun 23 '15 22:06 dkushner

+1

BLaurent avatar Oct 14 '15 06:10 BLaurent