Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/mucsi96/di-require.js
- Owner: mucsi96
- Created: 2014-05-11T13:18:29.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-05-11T14:44:48.000Z (over 10 years ago)
- Last Synced: 2024-10-12T03:13:07.332Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 141 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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 ##