File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ export class Container {
70
70
let service = this . findService ( identifier ) ;
71
71
72
72
// find if instance of this object already initialized in the container and return it if it is
73
- if ( service && service . instance )
73
+ if ( service && service . instance !== null && service . instance !== undefined )
74
74
return service . instance as T ;
75
75
76
76
// if named service was requested and its instance was not found plus there is not type to know what to initialize,
Original file line number Diff line number Diff line change @@ -9,6 +9,34 @@ describe("Container", function() {
9
9
10
10
beforeEach ( ( ) => Container . reset ( ) ) ;
11
11
12
+ describe ( "get" , ( ) => {
13
+
14
+ it ( "should be able to get a boolean" , ( ) => {
15
+ const booleanTrue = "boolean.true" ;
16
+ const booleanFalse = "boolean.false" ;
17
+ Container . set ( booleanTrue , true ) ;
18
+ Container . set ( booleanFalse , false ) ;
19
+
20
+ Container . get ( booleanTrue ) . should . be . true ;
21
+ Container . get ( booleanFalse ) . should . be . false ;
22
+ } ) ;
23
+
24
+ it ( "should be able to get an empty string" , ( ) => {
25
+ const emptyString = "emptyString" ;
26
+ Container . set ( emptyString , "" ) ;
27
+
28
+ Container . get ( emptyString ) . should . be . eq ( "" ) ;
29
+ } ) ;
30
+
31
+ it ( "should be able to get the 0 number" , ( ) => {
32
+ const zero = "zero" ;
33
+ Container . set ( zero , 0 ) ;
34
+
35
+ Container . get ( zero ) . should . be . eq ( 0 ) ;
36
+ } ) ;
37
+
38
+ } ) ;
39
+
12
40
describe ( "set" , function ( ) {
13
41
14
42
it ( "should be able to set a class into the container" , function ( ) {
You can’t perform that action at this time.
0 commit comments