假設(shè)您有以下操作export const startAddExpense = (expenseData = {}) => { return (dispatch) => { const { description = '', note = '', amount = 0, createdAt = 0 } = expenseData; const expense = { description, note, amount, createdAt }; return database.ref('expenses').push(expense).then((ref) => { dispatch(addExpense({ id: ref.key, ...expense })); }); };};我將費(fèi)用數(shù)據(jù)存儲到數(shù)據(jù)庫(在我的情況下是火庫),然后將addExpense函數(shù)發(fā)送到商店這是對它的測試。test('should add expense to database and store', (done) => { const store = createMockStore({}); const expenseData = { description: 'Mouse', amount: 3000, note: 'This one is better', createdAt: 1000 }; store.dispatch(startAddExpense(expenseData)).then(() => { expect(1).toBe(1); done(); });});done() 函數(shù)的含義是什么?這是否意味著回調(diào)函數(shù)應(yīng)該等到在 firebase 數(shù)據(jù)庫中插入數(shù)據(jù)完成?謝謝 西奧
完成()函數(shù)的含義
慕尼黑的夜晚無繁華
2022-09-16 21:46:47