-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec2985b
commit cee7252
Showing
4 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import TinyDiInjectableBase from '../dist/injectable'; | ||
|
||
export default class MyClass extends TinyDiInjectableBase { | ||
constructor(private dep: any) { | ||
super(); | ||
} | ||
} | ||
MyClass.$inject = { | ||
deps: ['dependency'], | ||
callAs: 'class' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
///<reference path="../tiny-di.d.ts" /> | ||
import TinyDiInjectableBase from '../dist/injectable'; | ||
|
||
describe('typescript class', () => { | ||
it('can define $inject property', () => { | ||
class MyClass extends TinyDiInjectableBase {} | ||
MyClass.$inject = ['dependency']; | ||
expect(MyClass.$inject).toBeDefined(); | ||
}); | ||
|
||
it('can be loaded by tiny-di', () => { | ||
let tiny = require('../dist'); | ||
let injector: TinyDiInjector = new tiny(); | ||
injector.setResolver(resolver); | ||
injector.bind('dependency').to('exampleDep'); | ||
injector.bind('myClassInstance').load(__dirname + '/exampleclass.js'); | ||
|
||
let instance = injector.get('myClassInstance'); | ||
expect(instance.dep).toEqual('exampleDep'); | ||
}); | ||
}); | ||
|
||
/** | ||
* define resolver to load default exported classes | ||
*/ | ||
function resolver(module: string) { | ||
return require(module).default; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"noImplicitAny": true, | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true, | ||
"module": "commonjs", | ||
"sourceMap": true, | ||
"declaration": true, | ||
"target": "es5", | ||
"outDir": "buildspec" | ||
}, | ||
|
||
"exclude": [ | ||
"node_modules", | ||
"src", | ||
"buildspec" | ||
] | ||
} |