mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
Rewrite existing specs
This commit is contained in:
@@ -7,13 +7,25 @@ describe "ordersCtrl", ->
|
||||
{id: 10, name: 'Ten', status: 'open', distributors: [{id: 1, name: 'One'}]}
|
||||
{id: 20, name: 'Twenty', status: 'closed', distributors: [{id: 2, name: 'Two', status: 'closed'}]}
|
||||
]
|
||||
SortOptions = {
|
||||
predicate: "",
|
||||
reverse: false
|
||||
}
|
||||
|
||||
beforeEach ->
|
||||
scope = {}
|
||||
shops = []
|
||||
orderCycles = [
|
||||
{id: 10, name: 'Ten', status: 'open', distributors: [{id: 1, name: 'One'}]}
|
||||
{id: 20, name: 'Twenty', status: 'closed', distributors: [{id: 2, name: 'Two', status: 'closed'}]}
|
||||
]
|
||||
|
||||
module('admin.orders')
|
||||
inject ($controller) ->
|
||||
ctrl = $controller 'ordersCtrl', {$scope: scope, $attrs: attrs, shops: shops, orderCycles: orderCycles}
|
||||
module 'admin.orders', ($provide)->
|
||||
$provide.provider('shops', shops)
|
||||
$provide.provider('orderCycles', orderCycles)
|
||||
inject (_$injector_, $controller) ->
|
||||
$injector = _$injector_
|
||||
ctrl = $controller 'ordersCtrl', {$scope: scope, $attrs: attrs, $injector: $injector, SortOptions: SortOptions}
|
||||
|
||||
it "initialises name_and_status", ->
|
||||
expect(scope.orderCycles[0].name_and_status).toEqual "Ten (open)"
|
||||
|
||||
@@ -18,17 +18,17 @@ describe "Orders service", ->
|
||||
result = response = null
|
||||
|
||||
beforeEach ->
|
||||
response = [{ id: 5, name: 'Order 1'}]
|
||||
response = { orders: [{ id: 5, name: 'Order 1'}], pagination: {page: 1, pages: 1, results: 1} }
|
||||
$httpBackend.expectGET('/admin/orders.json').respond 200, response
|
||||
result = Orders.index()
|
||||
$httpBackend.flush()
|
||||
|
||||
it "stores returned data in @byID, with ids as keys", ->
|
||||
# OrderResource returns instances of Resource rather than raw objects
|
||||
expect(Orders.byID).toDeepEqual { 5: response[0] }
|
||||
expect(Orders.byID).toDeepEqual { 5: response.orders[0] }
|
||||
|
||||
it "stores returned data in @pristineByID, with ids as keys", ->
|
||||
expect(Orders.pristineByID).toDeepEqual { 5: response[0] }
|
||||
expect(Orders.pristineByID).toDeepEqual { 5: response.orders[0] }
|
||||
|
||||
it "returns an array of orders", ->
|
||||
expect(result).toDeepEqual response
|
||||
|
||||
Reference in New Issue
Block a user