0

我的页面上有一个 ajax 动画扩展器,它可以在不同的事件上更改按钮颜色,如下所示:

按钮和扩展代码是:

 asp:Button ID="target" runat="server" Text="Animate Me" OnClientClick="return false;">
        /asp:Button>
        aspext:AnimationExtender ID="extender" runat="server" TargetControlID="target">
            Animations>
                OnLoad><StyleAction Attribute="backgroundColor" Value="red" /></OnLoad>
                OnClick><StyleAction Attribute="backgroundColor" Value="blue" /></OnClick>
                OnMouseOver><StyleAction Attribute="backgroundColor" Value="blue" />/OnMouseOver>
                <OnMouseOut><StyleAction Attribute="backgroundColor" Value="green" /></OnMouseOut>
                OnHoverOver><StyleAction Attribute="color" Value="blue" /></OnHoverOver>
                OnHoverOut><StyleAction Attribute="color" Value="yellow" /></OnHoverOut>
            /Animations>
        /aspext:AnimationExtender>

我在 document.ready 上编写了 Qunit 测试,它与按钮的背景颜色和加载时的预期值相匹配,就像这样。

    $(document).ready(function () {
        module('Animation OnLoad tests');
        test(' Animation OnLoad ', function () {
                panel = $('#target');
                var actual = panel.css("background-color");
                equals(actual, "red", 'Event failed to fire');                           
        });
    });  

但问题是在扩展器更改按钮颜色之前运行测试,我也尝试了页面加载而不是 document.ready 但同样的问题。请建议我解决这个问题。

谢谢。

4

1 回答 1

1

看看如何使用stop()start()编写异步测试。不过,您需要一个回调才能开始通话。

于 2011-02-26T13:33:08.687 回答