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 に答える