简体   繁体   English

提交表单后,编写 Ember Octane 组件测试以检查 state 是否正确?

[英]Write Ember Octane Component test to check if state is correct after I submit a form?

I want to write a test such that when I submit a string, then a @tracked array =[0,0,0] field will change.我想编写一个测试,这样当我提交一个字符串时,@tracked array =[0,0,0] 字段将会改变。 I have a simple <Textarea @value={{ input0 }} ></Textarea> for hbs.我有一个简单的<Textarea @value={{ input0 }} ></Textarea>用于 hbs。
if input is 1 then the tracked array becomes [0,1,0] .如果输入为1 ,则跟踪数组变为[0,1,0] How do I do this??我该怎么做呢?? So far I have the following code that DOESN'T work:到目前为止,我有以下代码不起作用:

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { click, render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Component | array', function(hooks) {
    setupRenderingTest(hooks);



    test('Textarea should display PLACE [0,1,0]"', async function(assert) {

        await render(hbs`<Array />`);
        assert.equal(find('textarea').value, 'testing"')
      });

});

Welcome to Stack Overflow!欢迎来到堆栈溢出!

It looks like you are being trolled by window.find , which isn't what you want, you need find from @ember/test-helpers .看起来你被window.find控制了,这不是你想要的,你需要从@ember/test-helpers find

Replace:代替:

import { click, render } from '@ember/test-helpers';

with:和:

import { click, find, render } from '@ember/test-helpers';

Good Luck!祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM