File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,7 +67,9 @@ cocktail = {
6767 }
6868 } ,
6969
70-
70+ /**
71+ * @public
72+ */
7173 use : function ( annotation ) {
7274 var name = annotation . name || ( annotation . prototype && annotation . prototype . name ) ,
7375 processor = { } ;
Original file line number Diff line number Diff line change @@ -183,4 +183,45 @@ describe('cocktail', function(){
183183 } ) ;
184184
185185 } ) ;
186+
187+ describe ( 'Use' , function ( ) {
188+
189+ describe ( 'use(Class)' , function ( ) {
190+ var MyAnnotation = function ( ) { } ,
191+ processors ;
192+
193+ it ( 'adds MyAnnotation Class as a custom processor' , function ( ) {
194+ MyAnnotation . prototype . name = '@myannotation' ;
195+
196+ cocktail . use ( MyAnnotation ) ;
197+
198+ processors = cocktail . getProcessors ( ) ;
199+
200+ expect ( processors ) . to . have . property ( '@myannotation' ) ;
201+
202+ expect ( processors [ '@myannotation' ] ) . to . be . equal ( MyAnnotation ) ;
203+
204+ } ) ;
205+
206+ } ) ;
207+
208+
209+ describe ( 'use(Object)' , function ( ) {
210+ var MyAnnotation = { name : '@myannotation' } ,
211+ processors ;
212+
213+ it ( 'does not add MyAnnotation Object as a custom processor' , function ( ) {
214+ cocktail . use ( MyAnnotation ) ;
215+
216+ processors = cocktail . getProcessors ( ) ;
217+
218+ expect ( processors ) . to . not . have . property ( '@myannotation' ) ;
219+
220+ expect ( processors [ '@myannotation' ] ) . to . be . equal ( undefined ) ;
221+
222+ } ) ;
223+
224+ } ) ;
225+
226+ } ) ;
186227} ) ;
Original file line number Diff line number Diff line change @@ -97,6 +97,37 @@ describe('Annotation Processor @properties', function(){
9797
9898 } ) ;
9999
100+ it ( 'its setters modify the property and it is returned by its getter' , function ( ) {
101+ var instance = new MyClass ( ) ,
102+ stringVal = 'VALUE' ;
103+
104+ instance . setName ( stringVal ) ;
105+
106+ expect ( instance . name ) . to . be . equal ( stringVal ) ;
107+ expect ( instance . getName ( ) ) . to . be . equal ( stringVal ) ;
108+ } ) ;
109+ } ) ;
110+
111+ describe ( 'Does nothing if parameter is not a plain and non empty object' , function ( ) {
112+ var sut = new Properties ( ) ,
113+ MyClass = function ( ) { } ;
114+
115+
116+ it ( 'keeps the prototype untouched if no property is defined in the param' , function ( ) {
117+ sut . setParameter ( { } ) ;
118+ sut . process ( MyClass ) ;
119+ expect ( MyClass . prototype ) . to . be . empty ;
120+ } ) ;
121+
122+ it ( 'keeps the prototype untouched if param is not a plain object' , function ( ) {
123+ var CustomClass = function ( ) { } ;
124+
125+ CustomClass . prototype . value = 1 ;
126+
127+ sut . setParameter ( new CustomClass ( ) ) ;
128+ sut . process ( MyClass ) ;
129+ expect ( MyClass . prototype ) . to . be . empty ;
130+ } ) ;
100131
101132
102133 } ) ;
You can’t perform that action at this time.
0 commit comments