13
我一直在從this tutorial工作,並有谷歌搜索廣告的噁心,但我似乎無法得到似乎是一個微不足道的單元測試運行ngAnimate
。ngAnimate 1.4.7單元測試不調用動畫函數
我有ngAnimate
在應用程序中運行良好。所有的Angular核心庫都是1.4.7版本。
模塊
angular.module 'MyAnimation', [ 'ngAnimate' ]
.animation '.added-class', ->
addClass: (element, className, done) ->
console.log 'add class triggered'
element.css 'opacity', '0.5'
done()
測試
describe 'MyAnimation', ->
beforeEach -> module 'ngAnimate'
beforeEach -> module 'ngAnimateMock'
beforeEach -> module 'MyAnimation'
it 'animates', -> inject ($animate, $rootScope, $rootElement) ->
$animate.enabled(true)
divElement = angular.element '<div>my div</div>'
# Kick off initial digest loop in which no animations are run.
$rootScope.$digest()
# Trigger animation.
$animate.addClass divElement, 'added-class'
$rootScope.$digest()
# Tried this, doesn't seem to do anything.
# $animate.flush()
# Results in AssertionError: expected '' to equal '0.5'
expect(divElement.css('opacity')).to.eq '0.5'
我敢肯定,該模塊被包括在測試,但觸發$animate.enter
甚至不把我的log
輸出。
我已經嘗試過與其他$animate
函數一起使用,並且我無處可去。幫幫我?