我想如果某些的javascript(使用jQuery或任何其他框架)來測試應用到一定HTML代碼將在頁面上創建某些行爲。例如:有沒有辦法進行單元測試unobstrusive jQuery的場景
如果我有HTML(寫在一個測試爲Stub)
<div class="order">
<div class="id">15</div>
<div class="client">John</div>
</div>
而且我已經包括JS文件(寫在測試中也):
jquery.js
orders.js (the one I want to test)
而測試的主要部分(語法想象的)
part 1:
'client'.is 'hidden'
part 2:
'order'.click
'client'.should_be visible
我想測試通過才orders.js有這樣的代碼:
$(function(){
$('.client').hide();
$('.order').click(function(){
$(this).children('.client').show();
});
});
我想,我可以做這樣的事情與rspec的功能或黃瓜,但是否有任何更具體的框架這樣的測試?任何幫助,將不勝感激。