@@ -4,11 +4,14 @@ var nextTick = Vue.nextTick
44
55describe ( 'Directive' , function ( ) {
66
7- var el = { } // simply a mock to be able to run in Node
8- var vm , def
9-
7+ var el , vm , def
108 beforeEach ( function ( ) {
9+ el = document . createElement ( 'div' )
1110 def = {
11+ params : [ 'foo' ] ,
12+ paramWatchers : {
13+ foo : jasmine . createSpy ( 'foo' )
14+ } ,
1215 bind : jasmine . createSpy ( 'bind' ) ,
1316 update : jasmine . createSpy ( 'update' ) ,
1417 unbind : jasmine . createSpy ( 'unbind' )
@@ -154,4 +157,32 @@ describe('Directive', function () {
154157 expect ( d . update ) . toBe ( def . update )
155158 expect ( def . update ) . toHaveBeenCalled ( )
156159 } )
160+
161+ it ( 'static params' , function ( ) {
162+ el . setAttribute ( 'foo' , 'hello' )
163+ var d = new Directive ( {
164+ name : 'test' ,
165+ def : def ,
166+ expression : 'a'
167+ } , vm , el )
168+ d . _bind ( )
169+ expect ( d . params . foo ) . toBe ( 'hello' )
170+ } )
171+
172+ it ( 'dynamic params' , function ( done ) {
173+ el . setAttribute ( ':foo' , 'a' )
174+ var d = new Directive ( {
175+ name : 'test' ,
176+ def : def ,
177+ expression : 'a'
178+ } , vm , el )
179+ d . _bind ( )
180+ expect ( d . params . foo ) . toBe ( vm . a )
181+ vm . a = 2
182+ nextTick ( function ( ) {
183+ expect ( def . paramWatchers . foo ) . toHaveBeenCalledWith ( 2 , 1 )
184+ expect ( d . params . foo ) . toBe ( vm . a )
185+ done ( )
186+ } )
187+ } )
157188} )
0 commit comments