Skip to content

Commit

Permalink
Fix spec using confirm pop up
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rioug committed Sep 2, 2024
1 parent af3aed8 commit 627c9ee
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 627c9ee

Please sign in to comment.