mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Fix spec using confirm pop up
For some reason, karma hang and fails with a timeout error if javascrpit `confirm` pop up isn't mocked. Plus fix spec to actually check the pop up has been displayed
This commit is contained in:
@@ -121,18 +121,24 @@ describe "LineItemsCtrl", ->
|
||||
scope.line_items = [ line_item1, line_item2 ]
|
||||
|
||||
it "show popup about order cancellation only on last item deletion", ->
|
||||
spyOn(window, "confirm").and.callFake(-> return true)
|
||||
spyOn(window, "ofnCancelOrderAlert")
|
||||
|
||||
scope.deleteLineItem(line_item2)
|
||||
expect(confirm).toHaveBeenCalled()
|
||||
expect(ofnCancelOrderAlert).not.toHaveBeenCalled()
|
||||
|
||||
scope.deleteLineItem(line_item1)
|
||||
expect(ofnCancelOrderAlert).toHaveBeenCalled()
|
||||
|
||||
it "deletes the line item", ->
|
||||
spyOn(window, "confirm").and.callFake(-> return true)
|
||||
spyOn(LineItems, "delete")
|
||||
|
||||
scope.deleteLineItem(line_item2)
|
||||
expect(confirm).toHaveBeenCalled()
|
||||
expect(LineItems.delete).toHaveBeenCalledWith(line_item2, jasmine.anything())
|
||||
|
||||
|
||||
describe "deleting 'checked' line items", ->
|
||||
line_item1 = line_item2 = line_item3 = line_item4 = null
|
||||
order1 = order2 = order3 = null
|
||||
|
||||
Reference in New Issue
Block a user