Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mucsi96/di-require.js

Nano javascript dependency injection module with require syntax
https://github.com/mucsi96/di-require.js

Last synced: 5 days ago
JSON representation

Nano javascript dependency injection module with require syntax

Awesome Lists containing this project

README

        

# Nano dependency injection module with require syntax #
## Examples ##
Let's define a module

(function () {
var alphaModule = function () {
return {
getName: function () {
return 'alpha';
}
};
};
define('alphaModule', alphaModule);
}());

And one more module

(function () {
var bravoModule = function () {
var alphaModule = require('alphaModule');
return {
getName: function () {
return alphaModule.getName() + 'Bravo';
}
};
};
define('bravoModule', bravoModule);
}());

And now we can easily test it!

describe('bravoModule', function () {
it('should be easily tested', function () {
var alphaModuleStub = {
getName: function () {
return 'stubAlpha';
}
};

stub('alphaModule', alphaModuleStub);
bravoModule = test('bravoModule');
expect(bravoModule.getName()).toEqual('stubAlphaBravo');
});
});

## Spec Runner Output ##