Fix js unit tests

This commit is contained in:
Pau Perez
2017-08-09 18:30:54 +02:00
committed by Rob Harrington
parent 5b1947429e
commit 47468df2a5
2 changed files with 8 additions and 8 deletions

View File

@@ -34,7 +34,7 @@ describe "LineItemsCtrl", ->
lineItem = { id: 7, quantity: 3, order: { id: 9 }, supplier: { id: 1 } }
httpBackend.expectGET("/admin/orders.json?q%5Bcompleted_at_gt%5D=SomeDate&q%5Bcompleted_at_lt%5D=SomeDate&q%5Bcompleted_at_not_null%5D=true&q%5Bstate_not_eq%5D=canceled").respond [order]
httpBackend.expectGET("/admin/line_items.json?q%5Border%5D%5Bcompleted_at_gt%5D=SomeDate&q%5Border%5D%5Bcompleted_at_lt%5D=SomeDate&q%5Border%5D%5Bcompleted_at_not_null%5D=true&q%5Border%5D%5Bstate_not_eq%5D=canceled").respond [lineItem]
httpBackend.expectGET("/admin/bulk_line_items.json?q%5Border%5D%5Bcompleted_at_gt%5D=SomeDate&q%5Border%5D%5Bcompleted_at_lt%5D=SomeDate&q%5Border%5D%5Bcompleted_at_not_null%5D=true&q%5Border%5D%5Bstate_not_eq%5D=canceled").respond [lineItem]
httpBackend.expectGET("/admin/enterprises/for_line_items.json?ams_prefix=basic&q%5Bsells_in%5D%5B%5D=own&q%5Bsells_in%5D%5B%5D=any").respond [distributor]
httpBackend.expectGET("/admin/order_cycles.json?ams_prefix=basic&as=distributor&q%5Borders_close_at_gt%5D=SomeDate").respond [orderCycle]
httpBackend.expectGET("/admin/enterprises/for_line_items.json?ams_prefix=basic&q%5Bis_primary_producer_eq%5D=true").respond [supplier]
@@ -106,7 +106,7 @@ describe "LineItemsCtrl", ->
describe "where the request is successful", ->
beforeEach ->
httpBackend.expectDELETE("/admin/orders/R12345678/line_items/1.json").respond "nothing"
httpBackend.expectDELETE("/admin/bulk_line_items/1.json").respond "nothing"
scope.deleteLineItem line_item1
httpBackend.flush()
@@ -115,7 +115,7 @@ describe "LineItemsCtrl", ->
describe "where the request is unsuccessful", ->
beforeEach ->
httpBackend.expectDELETE("/admin/orders/R12345678/line_items/1.json").respond 404, "NO CONTENT"
httpBackend.expectDELETE("/admin/bulk_line_items/1.json").respond 404, "NO CONTENT"
scope.deleteLineItem line_item1
httpBackend.flush()

View File

@@ -19,7 +19,7 @@ describe "LineItems service", ->
beforeEach ->
response = [{ id: 5, name: 'LineItem 1'}]
$httpBackend.expectGET('/admin/line_items.json').respond 200, response
$httpBackend.expectGET('/admin/bulk_line_items.json').respond 200, response
result = LineItems.index()
$httpBackend.flush()
@@ -41,7 +41,7 @@ describe "LineItems service", ->
beforeEach ->
lineItem = new LineItemResource({ id: 15, order: { number: '12345678'} })
$httpBackend.expectPUT('/admin/orders/12345678/line_items/15.json').respond 200, { id: 15, name: 'LineItem 1'}
$httpBackend.expectPUT('/admin/bulk_line_items/15.json').respond 200, { id: 15, name: 'LineItem 1'}
LineItems.save(lineItem).then( -> resolved = true)
$httpBackend.flush()
@@ -60,7 +60,7 @@ describe "LineItems service", ->
beforeEach ->
lineItem = new LineItemResource( { id: 15, order: { number: '12345678'} } )
$httpBackend.expectPUT('/admin/orders/12345678/line_items/15.json').respond 422, { error: 'obj' }
$httpBackend.expectPUT('/admin/bulk_line_items/15.json').respond 422, { error: 'obj' }
LineItems.save(lineItem).catch( -> rejected = true)
$httpBackend.flush()
@@ -115,7 +115,7 @@ describe "LineItems service", ->
lineItem = new LineItemResource({ id: 15, order: { number: '12345678'} })
LineItems.pristineByID[15] = lineItem
LineItems.byID[15] = lineItem
$httpBackend.expectDELETE('/admin/orders/12345678/line_items/15.json').respond 200, { id: 15, name: 'LineItem 1'}
$httpBackend.expectDELETE('/admin/bulk_line_items/15.json').respond 200, { id: 15, name: 'LineItem 1'}
LineItems.delete(lineItem, callback).then( -> resolved = true).catch( -> rejected = true)
$httpBackend.flush()
@@ -140,7 +140,7 @@ describe "LineItems service", ->
lineItem = new LineItemResource({ id: 15, order: { number: '12345678'} })
LineItems.pristineByID[15] = lineItem
LineItems.byID[15] = lineItem
$httpBackend.expectDELETE('/admin/orders/12345678/line_items/15.json').respond 422, { error: 'obj' }
$httpBackend.expectDELETE('/admin/bulk_line_items/15.json').respond 422, { error: 'obj' }
LineItems.delete(lineItem, callback).then( -> resolved = true).catch( -> rejected = true)
$httpBackend.flush()