酶-如何访问测试文件中的设置输入值?

时间:2019-07-26 06:17:27

标签: reactjs enzyme

我正在通过酶创建一个单元测试用例。在“ register.js”文件中,我在用户对象中设置了表单状态,但是在“ register-test.js”文件中,该状态的值被赋予了“ undefined”:-

Dim SQLCONN As New Npgsql.NpgsqlConnection
Dim SQLCMD As New Npgsql.NpgsqlCommand
SQLCONN.ConnectionString = 
"SERVER=localhost;PORT=5432;DATABASE=xxxx;Uid=postgres;Password=xxxx"
SQLCMD.Connection = SQLCONN
SQLCMD.CommandType = CommandType.StoredProcedure
SQLCMD.CommandText = "spx_temp_to_ext"
SQLCONN.Open()
SQLCMD.ExecuteNonQuery()
SQLCONN.Close()

在register.js文件中设置了用户对象状态

Expected: "dinesh"
Received: undefined

我正在尝试“ register-test.js”。

this.state = {
            user: {
                firstName: ''  
            },

1 个答案:

答案 0 :(得分:0)

wrapper.find('input[type="text"]').simulate('change', {target: {name: 'firstName', value: 'dinesh'}});


expect(wrapper.state().user.firstName).toEqual('dinesh');  

您的名字在用户名下