0
我需要編寫單元測試以幫助下面的Redux操作。 在Google中,我看到了一些示例,但他們編寫動作的方式似乎有很大不同,所以我在爲Redux動作編寫單元測試時面臨一些困難。Redux Action Unit Testing(Mocha&Chai)
下面是終極版的行動,我有:
import * as types from './readerTypes';
export const documentSuccessAction = (data) => {
return (dispatch, getState) => {
dispatch({
type: 'GET_METADATA_SUCCESS',
metadata: data.document
});
dispatch({
type: 'GET_DOCUMENT_SUCCESS',
document : data.documentContent
});
};
};
export const getDocument = (docID) => {
return (dispatch, getState) => dispatch({
type: 'API_REQUEST',
options: {
method: 'GET',
service: 'reader',
endpoint: `document/${docID}`,
actionTypes: {
loading: 'GET_DOCUMENT_LOADING',
success: documentSuccessAction,
error: 'GET_DOCUMENT_ERROR'
}
}
});
};
任何人都可以請幫我這個?
謝謝
你有什麼樣的困難?你有什麼嘗試,什麼不工作,請詳細說明。 – cinnaroll45