2017-02-27 11 views
0

私のアプリケーションルートでは、モーダルの開閉をレンダリングする方法についてemberのWebサイトから提供されています。 https://guides.emberjs.com/v1.10.0/cookbook/user_interface_and_interaction/using_modal_dialogs/アプリケーションルートでモーダルをレンダリングするためのQunit

export default Ember.Route.extend({ 
    actions: { 
     openModal: function(name, controllerName) { 
     this.render(name, { 
      into: 'application', 
      outlet: 'modal', 
      controller: controllerName 
     }); 
     }, 
     closeModal: function() { 
     this.disconnectOutlet({ 
      outlet: 'modal', 
      parentView: 'application' 
     }); 
     } 
    } 
}); 

私は、レンダリングアクションのためのユニットテストを行う方法の例を見つけるためにしようとしてきたが、多くのドキュメントを見つけることができませんでした。

アプリケーションルートのユニットテストでは、ルート上のアクションをトリガし、何が起こるのかを見るために、これは私が持っているものであり、私が得るエラーです。誰もが提供できる指導をありがとうございます。

test('route open modal', function(assert) { 
    let route = this.subject(); 
    route.send('openModal', 'cancel-modal'); 
    assert.ok(route); 
}); 


Died on test #1  at Module.callback (http://localhost:4200/exampleApp/assets/tests.js:1113:24) 
    at Module.exports (http://localhost:4200/exampleApp/assets/vendor.js:140:32) 
    at requireModule (http://localhost:4200/exampleApp/assets/vendor.js:32:18) 
    at TestLoader.require (http://localhost:4200/exampleApp/assets/test-support.js:7124:7) 
    at TestLoader.loadModules (http://localhost:4200/exampleApp/assets/test-support.js:7116:14) 
    at Function.TestLoader.load (http://localhost:4200/exampleApp/assets/test-support.js:7146:22) 
    at http://localhost:4200/exampleApp/assets/test-support.js:7030:18: Cannot read property 'state' of [email protected] 31 ms 
Source:  
TypeError: Cannot read property 'state' of undefined 
    at parentRoute (http://localhost:4200/exampleApp/assets/vendor.js:41309:64) 
    at buildRenderOptions (http://localhost:4200/exampleApp/assets/vendor.js:41371:27) 
    at Class.render (http://localhost:4200/exampleApp/assets/vendor.js:41191:27) 
    at Class.openModal (http://localhost:4200/exampleApp/assets/exampleApp.js:1118:14) 
    at Class.send (http://localhost:4200/exampleApp/assets/vendor.js:40471:39) 
    at Class.superWrapper [as send] (http://localhost:4200/exampleApp/assets/vendor.js:54491:22) 
    at Object.<anonymous> (http://localhost:4200/exampleApp/assets/tests.js:1115:11) 
    at runTest (http://localhost:4200/exampleApp/assets/test-support.js:3471:30) 
    at Test.run (http://localhost:4200/exampleApp/assets/test-support.js:3457:6 

答えて

0

2つのもの。

  1. あなたは時代遅れの解決策を使用しています。リンクしているドキュメントページは2歳です。

    代わりに、モーダルダイアログに最新のアドオンを使用してください。私は個人的にliquid-tetherを好むが、many other solutions availableがある。

  2. 何かをレンダリングしようとしている間に単体テストを使用しています。ユニットテストは、メソッドを実行して戻り値をチェックするためのものです。レンダリングされるモーダルダイアログをテストするには、受け入れテストが必要です。

関連する問題