1+ module ( "Discourse.Singleton" ) ;
2+
3+ test ( "current" , function ( ) {
4+ var DummyModel = Ember . Object . extend ( { } ) ;
5+ DummyModel . reopenClass ( Discourse . Singleton ) ;
6+
7+ var current = DummyModel . current ( ) ;
8+ present ( current , 'current returns the current instance' ) ;
9+ equal ( current , DummyModel . current ( ) , 'calling it again returns the same instance' ) ;
10+ notEqual ( current , DummyModel . create ( { } ) , 'we can create other instances that are not the same as current' ) ;
11+ } ) ;
12+
13+ test ( "currentProp reading" , function ( ) {
14+ var DummyModel = Ember . Object . extend ( { } ) ;
15+ DummyModel . reopenClass ( Discourse . Singleton ) ;
16+ var current = DummyModel . current ( ) ;
17+
18+ blank ( DummyModel . currentProp ( 'evil' ) , 'by default attributes are blank' ) ;
19+ current . set ( 'evil' , 'trout' ) ;
20+ equal ( DummyModel . currentProp ( 'evil' ) , 'trout' , 'after changing the instance, the value is set' ) ;
21+ } ) ;
22+
23+ test ( "currentProp writing" , function ( ) {
24+ var DummyModel = Ember . Object . extend ( { } ) ;
25+ DummyModel . reopenClass ( Discourse . Singleton ) ;
26+
27+ blank ( DummyModel . currentProp ( 'adventure' ) , 'by default attributes are blank' ) ;
28+ var result = DummyModel . currentProp ( 'adventure' , 'time' ) ;
29+ equal ( result , 'time' , 'it returns the new value' ) ;
30+ equal ( DummyModel . currentProp ( 'adventure' ) , 'time' , 'after calling currentProp the value is set' ) ;
31+
32+ DummyModel . currentProp ( 'count' , 0 ) ;
33+ equal ( DummyModel . currentProp ( 'count' ) , 0 , 'we can set the value to 0' ) ;
34+
35+ DummyModel . currentProp ( 'adventure' , null ) ;
36+ equal ( DummyModel . currentProp ( 'adventure' ) , null , 'we can set the value to null' ) ;
37+ } ) ;
0 commit comments