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:
Gaetan Craig-Riou
2024-09-02 12:18:44 +10:00
parent af3aed827a
commit 627c9eede2

View File

@@ -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