我正在使用Jasmine灯具来测试我的下拉菜单方法。此功能可以检测下拉菜单是否超出了网页的边界,如果该方法检测到下拉菜单超出了边界,则下拉菜单的生成方向将变为向上。
现在,我正在使用Jasmine夹具来创建示例HTML来测试此方法,我创建了带有菜单的下拉按钮,但是我不知道如何定义页面的大小。例如,我想使该页面的尺寸很小,以便下拉菜单的方向超出范围并变为向上,但是我不知道该怎么做。我应该在beforeEach()或Fixture.html中写东西吗?
我的单元测试功能:
describe('#determineDropMenuDirection', function() { beforeEach(function() { loadFixtures('dropdown_menu_fixture.html'); }); describe('when the dropdown menu does not exceed the bound of the page', function(){ it('generates a dropdown menu with a downward direction', function(){ }); }); describe('when the dropdown menu exceeds the bounds of the page', function(){ it('generates a dropdown menu with a upward direction', function(){ }); });
这是我的fixture.html文件
<HTML>
<body>
<table weith="1024" heigth="768">
<span class="dropdown">
<button id="dropdown_button" class="btn btn-default btn-small dropdown-toggle" data-toggle="dropdown">Dropdown
<b class="caret"></b>
</button>
<ul class="dropdown-menu action-dropdown">
<li>
<a>Item 1</a>
</li>
<li>
<a>Item 2</a>
</li>
<li>
<a>Item 3</a>
</li>
</ul>
</span>
</table>
我正在使用Jasmine灯具来测试我的下拉菜单方法。此功能可以检测下拉菜单是否超出了网页的范围,下拉菜单的生成方向为...