0

だから私は角度のあるプロジェクトを構築しています...そして、「twitterエントリ」、「Facebookエントリ」などの子クラスを持つ「エントリ」と呼ばれるクラスがあります.

理想的には、1 つの仕様を作成し、その仕様を通じてすべての子クラスを実行したいと考えています。私はそれを行う方法を理解していません。

ジャスミン仕様を関数化する方法について何か提案はありますか?

4

1 に答える 1

0

Jasmine の期待を実行する標準の JS 関数を作成し、個別の仕様を介して各子クラスを渡します。何かのようなもの:

describe("my multi-class spec suite", function(){
    //common specs for each child class
    var myExpectations = function(childClass) {
        expect(childClass).toBeDefined();
        expect(childClass.inheritedMethod()).toEqual("some common value");
        ...
    };

    //pass in your children classes
    it('should have twitter entries that behave', function(){
        myExpectations(new TwitterEntry());
    });

    it('should have facebook entries that behave', function(){
        myExpectations(new FacebookEntry());
    });
});
于 2012-12-06T16:42:06.630 に答える