2016-08-30 2 views
1

다음은 ember-qunit의 기본 구성 요소/통합 테스트입니다. {{my-component}}이 어디ember-qunit은 통합 테스트에서 구성 요소를 어떻게 렌더링합니까?

addon/ 
.. components/ 
.... my-component/ 
...... component.js 
...... style.less 
...... template.hbs 
app/ 
.. components/ 
.... my-component.js 
...... component.js 
tests/ 
.. integration/ 
.... components/ 
...... my-component-test.js 

어떻게 엠버 결정 않습니다

import { moduleForComponent, test } from 'ember-qunit'; 
import hbs from 'htmlbars-inline-precompile'; 

moduleForComponent('my-component', 'TODO: put something here', { 
    integration: true 
}); 

test('it renders', function(assert) { 
    this.render(hbs`{{my-component}}`); 

    console.log('This is the rendered element', this.$()[0]); 
    assert.ok(false); 
}); 

는이 같은 디렉토리 구조를 가진 엠버 - 부가 기능이?

이이 같은 정맥에 가지이다, 난 그냥 내보내기/가져 와서 addon 구성 요소에 정규 app 구성 요소를 연결 한
How does Ember-CLI precompile templates?

편집 주석으로 당 1

그것.

app/components/my-component/component.js 
export { default } from 'my-application/components/my-component' 

그러나, 콘솔 로그는이를 보여줍니다 관례

This is the rendered element <div id="ember234 class="ember-view"> 
           <!----> 
          </div> 

답변

2

합니다.

Ember app/components 디렉토리 또는 app/components/templates 디렉토리 또는 app/helpers 디렉토리 아래에 my-component이라는 파일을 찾으십시오.

export { default } from 'my-addon/components/my-component'; 
+0

두 가지 질문을 여기에 : 당신이 당신의 addon/components 디렉토리 아래 my-component를 정의하면

, 당신은 당신의 app/components 디렉토리 또는 tests/dummy/app/components 디렉토리와 같은 그것을 다시 정의해야합니다. 첫째, 컴포넌트의 다른 부분은 템플릿과 스타일 (업데이트 된 파일 구조와 함께)과 addons의'component.js '와 같이 어떻게 구성되어 있습니까? 둘째로, 컴포넌트가'tests'와'app'에 정의되어 있다면, 디폴트는 무엇입니까? (수정 1로 업데이트 된 질문) – shane

+1

'component.js'에서'layout'을 가져 옵니까? 템플릿을 가져 오지 않는 것 같습니다. [this addon] (https://github.com/tubitak-bilgem-yte/ember-contextual-table)을보십시오. 통합 테스트가 있습니다. – ykaragol

+0

'import template from './template'을 추가하려고했습니다. & layout : 템플릿을 addon/components/my-component/component.js에 보내기 전에 불행히도 – shane