Skip to content

Commit

Permalink
Merge pull request #12834 from rioug/12832-Fix-karma-test
Browse files Browse the repository at this point in the history
Fix karma test
  • Loading branch information
dacook authored Sep 2, 2024
2 parents f9a7634 + 703ad26 commit 9cfcab4
Showing 1 changed file with 11 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 Expand Up @@ -165,10 +171,14 @@ describe "LineItemsCtrl", ->

it "asks for confirmation only if orders will be canceled", ->
spyOn(window, "ofnCancelOrderAlert")

line_item3.checked = true
scope.deleteLineItems(scope.line_items)

line_item1.checked = true
scope.deleteLineItems(scope.line_items)
expect(ofnCancelOrderAlert).toHaveBeenCalled()


describe "check boxes for line items", ->
line_item1 = line_item2 = null
Expand Down

0 comments on commit 9cfcab4

Please sign in to comment.