React,Redux,Chai我如何等待测试的有效载荷?

时间:2017-11-14 15:39:01

标签: reactjs redux chai

我想我必须改写我的问题。如何触发操作并等待响应。我正在使用firebase来保存我的数据和减少thunk。

import {myAction} from "../../src/js/actions/index";


describe('My Description', () => {
    it('has correct payload', () => {

        const action = myAction();

        expect(action.payload).log(); //this doesn't work
        expect(action.payload).to.equal({some:"json"}); 
        //this fails but I want to see what was returned so I can fix it
    })
})

//我的行动

export function myAction(data){

return dispatch => {
    //firebase
    const sectionKey =  agendaRef.push().key;
    agendaRef.child(   sectionKey  ).set(data);
    dispatch({
        type: ADD_ITEM_SAVE_SUCCESS,
        //payload: true
    })

  }
}

1 个答案:

答案 0 :(得分:-2)

我已更新您的代码以在控制台日志语句中打印有效内容值。

MyList.RemoveAll(x=>x.Number != "04");