-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OEUI-237: discard a drug order from the draft list (#178)
- Loading branch information
1 parent
60c1fe1
commit 9f6dc0d
Showing
5 changed files
with
64 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,65 @@ | ||
import { | ||
ADD_DRAFT_ORDER_SUCCESS, | ||
DELETE_DRAFT_ORDER_SUCCESS, | ||
DELETE_ALL_DRAFT_ORDERS_SUCCESS | ||
ADD_DRAFT_DRUG_ORDER_SUCCESS, | ||
DELETE_DRAFT_DRUG_ORDER_SUCCESS, | ||
DELETE_ALL_DRAFT_DRUG_ORDERS_SUCCESS | ||
} from '../../app/js/actions/actionTypes'; | ||
import { | ||
addDraftOrder, | ||
deleteDraftOrder, | ||
deleteAllDraftOrders, | ||
deleteAllDrugDraftOrders, | ||
} from '../../app/js/actions/draftTableAction'; | ||
|
||
describe('Discontinue Order Actions', () => { | ||
beforeEach(() => moxios.install()); | ||
afterEach(() => moxios.uninstall()); | ||
|
||
it('should dispatch a draft order successfuly', async (done) => { | ||
it('should dispatch ADD_DRAFT_DRUG_ORDER_SUCCESS successfully', async (done) => { | ||
const order = { | ||
action: 'DISCONTINUE', | ||
drugName: 'panadol', | ||
orderNumber: 3 | ||
}; | ||
|
||
const expectedActions = { | ||
ADD_DRAFT_ORDER_SUCCESS, | ||
const expectedActions = [{ | ||
type: ADD_DRAFT_DRUG_ORDER_SUCCESS, | ||
order, | ||
} | ||
}]; | ||
|
||
const store = mockStore({}); | ||
|
||
await store.dispatch(addDraftOrder(order), () => { | ||
expect(store.getActions()).toEqual(expectedActions); | ||
}); | ||
await store.dispatch(addDraftOrder(order)); | ||
expect(store.getActions()).toEqual(expectedActions); | ||
done(); | ||
}); | ||
|
||
it('should dispatch deleting a draft order successfuly', async (done) => { | ||
it('should dispatch DELETE_DRAFT_DRUG_ORDER_SUCCESS successfully', async (done) => { | ||
const order = { | ||
action: 'DISCONTINUE', | ||
drugName: 'panadol', | ||
orderNumber: 3 | ||
}; | ||
|
||
const expectedActions = { | ||
DELETE_DRAFT_ORDER_SUCCESS, | ||
const expectedActions = [{ | ||
type: DELETE_DRAFT_DRUG_ORDER_SUCCESS, | ||
order, | ||
} | ||
}]; | ||
|
||
const store = mockStore({}); | ||
|
||
await store.dispatch(deleteDraftOrder(order), () => { | ||
expect(store.getActions()).toEqual(expectedActions); | ||
}); | ||
await store.dispatch(deleteDraftOrder(order)); | ||
expect(store.getActions()).toEqual(expectedActions); | ||
done(); | ||
}); | ||
|
||
it('should dispatch deleting all draft orders successfuly', async (done) => { | ||
const expectedActions = { | ||
DELETE_ALL_DRAFT_ORDERS_SUCCESS, | ||
} | ||
it('should dispatch DELETE_ALL_DRAFT_DRUG_ORDERS_SUCCESS successfully', async (done) => { | ||
const expectedActions = [{ | ||
type: DELETE_ALL_DRAFT_DRUG_ORDERS_SUCCESS, | ||
}]; | ||
|
||
const store = mockStore({}); | ||
|
||
await store.dispatch(deleteAllDraftOrders(), () => { | ||
expect(store.getActions()).toEqual(expectedActions); | ||
}); | ||
await store.dispatch(deleteAllDrugDraftOrders()); | ||
expect(store.getActions()).toEqual(expectedActions); | ||
done(); | ||
}); | ||
}); |