@@ -236,88 +236,40 @@ describe('UNIT: Directive', function () {
236236
237237 } )
238238
239- describe ( '.apply()' , function ( ) {
240-
241- var test ,
242- applyTest = function ( val ) { test = val }
243- directives . applyTest = applyTest
244-
245- it ( 'should invole the _update function' , function ( ) {
246- var d = Directive . parse ( 'applyTest' , 'abc' , compiler )
247- d . apply ( 12345 )
248- assert . strictEqual ( test , 12345 )
249- } )
250-
251- it ( 'should apply the filter if there is any' , function ( ) {
252- var d = Directive . parse ( 'applyTest' , 'abc | currency £' , compiler )
253- d . apply ( 12345 )
254- assert . strictEqual ( test , '£12,345.00' )
255- } )
256-
257- } )
258-
259239 describe ( '.update()' , function ( ) {
260240
261241 var d = Directive . parse ( 'text' , 'abc' , compiler ) ,
262- applied = false
263- d . apply = function ( ) {
264- applied = true
242+ updated = false
243+ d . _update = function ( ) {
244+ updated = true
265245 }
266246
267- it ( 'should apply () for first time update, even with undefined' , function ( ) {
247+ it ( 'should call _update () for first time update, even with undefined' , function ( ) {
268248 d . update ( undefined , true )
269- assert . strictEqual ( applied , true )
249+ assert . strictEqual ( updated , true )
270250 } )
271251
272- it ( 'should apply () when a different value is given' , function ( ) {
273- applied = false
252+ it ( 'should _update () when a different value is given' , function ( ) {
253+ updated = false
274254 d . update ( 123 )
275255 assert . strictEqual ( d . value , 123 )
276- assert . strictEqual ( applied , true )
256+ assert . strictEqual ( updated , true )
277257 } )
278258
279- it ( 'should not apply () if the value is the same' , function ( ) {
280- applied = false
259+ it ( 'should not _update () if the value is the same' , function ( ) {
260+ updated = false
281261 d . update ( 123 )
282- assert . ok ( ! applied )
262+ assert . ok ( ! updated )
283263 } )
284264
285- } )
286-
287- describe ( '.refresh()' , function ( ) {
288-
289- var d = Directive . parse ( 'text' , 'abc' , compiler ) ,
290- applied = false ,
291- el = 1 , vm = 2 ,
292- value = {
293- $get : function ( ) {
294- return el + vm
295- }
265+ it ( 'should call applyFilter() is there are filters' , function ( ) {
266+ var filterApplied = false
267+ d . filters = [ ]
268+ d . applyFilters = function ( ) {
269+ filterApplied = true
296270 }
297- d . el = el
298- d . vm = vm
299- d . apply = function ( ) {
300- applied = true
301- }
302-
303- d . refresh ( value )
304-
305- it ( 'should set the value if value arg is given' , function ( ) {
306- assert . strictEqual ( d . value , value )
307- } )
308-
309- it ( 'should get its el&vm context and get correct computedValue' , function ( ) {
310- assert . strictEqual ( d . computedValue , el + vm )
311- } )
312-
313- it ( 'should call apply()' , function ( ) {
314- assert . ok ( applied )
315- } )
316-
317- it ( 'should not call apply() if computedValue is the same' , function ( ) {
318- applied = false
319- d . refresh ( )
320- assert . ok ( ! applied )
271+ d . update ( 234 )
272+ assert . ok ( filterApplied )
321273 } )
322274
323275 } )
0 commit comments