1

私の問題は、Waterline モデルの TDD を実行しようとしていることです。私が提示するテストは、私のスイートを構築するためのボイラープレートにすぎません。それにもかかわらず、彼らは正当な問題を提起します。主な問題は、Vows.js テストでモデルが必要なことです。テスト スコープではモデルが定義されていますが、Waterline パッケージから継承されたプロパティはありません。たとえば、「EducationLevel」のモデル コードは次のとおりです。

module.exports = {
  migrate: 'safe',
  tableName: 'education_levels',
  attributes: {
    id : { type: 'integer', required: true },
    description: { type: 'string', required: true },
    display_sort: { type: 'integer', required: true}
  }
};

そして、ここにいくつかのトライアルテストがあります:

vows = require('vows')
assert = require('assert')
EducationLevel = require('../api/models/EducationLevel')

vows.describe('tac_models').addBatch({
  'EducationLevel model' : {
    topic: function(){
      educationLevel = EducationLevel.create();
      return true;
    },
    'It exists': function (topic) {
      assert.equal(EducationLevel.create,undefined);
      assert.equal(EducationLevel.migrate,undefined);
    }
  }
}).export(module)

テストを実行すると、最初のアサーションは成功しましたが、2 番目のアサーションは成功しませんでした:

 vows spec/*
 ✗  


    EducationLevel model 
      ✗ It exists 
        » expected undefined, 
    got  'safe' (==) // tac_models.js:13 
  ✗ Broken » 1 broken (1.545s) 

これは、テストが EducationLevel 定義で明示的に宣言されているものだけを認識していることを示しています。「migrate」プロパティが定義されているのは、コードで明示的に定義しているためです。ウォーターラインメソッドの「作成」については知りません。従来のTDDを実用的にする方法でこれをどのように修正できますか?

4

0 に答える 0