mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Add test for removesInactiveExchanges
This commit is contained in:
@@ -119,12 +119,16 @@ angular.module('order_cycle', ['ngResource']).
|
||||
},
|
||||
|
||||
removeInactiveExchanges: function() {
|
||||
for(var i=0; i < this.order_cycle.incoming_exchanges.length; i++) {
|
||||
if(!this.order_cycle.incoming_exchanges[i].active) {
|
||||
this.order_cycle.incoming_exchanges.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
angular.forEach([this.order_cycle.incoming_exchanges,
|
||||
this.order_cycle.outgoing_exchanges],
|
||||
function(exchanges) {
|
||||
for(var i=0; i < exchanges.length; i++) {
|
||||
if(!exchanges[i].active) {
|
||||
exchanges.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}).
|
||||
|
||||
@@ -205,5 +205,26 @@ describe 'OrderCycle services', ->
|
||||
expect(OrderCycle.removeInactiveExchanges).toHaveBeenCalled()
|
||||
expect($window.location).toEqual(undefined)
|
||||
|
||||
it 'removes inactive exchanges', ->
|
||||
OrderCycle.order_cycle =
|
||||
incoming_exchanges: [
|
||||
{enterprise_id: "1", active: false}
|
||||
{enterprise_id: "2", active: true}
|
||||
{enterprise_id: "3", active: false}
|
||||
]
|
||||
outgoing_exchanges: [
|
||||
{enterprise_id: "4", active: true}
|
||||
{enterprise_id: "5", active: false}
|
||||
{enterprise_id: "6", active: true}
|
||||
]
|
||||
OrderCycle.removeInactiveExchanges()
|
||||
expect(OrderCycle.order_cycle.incoming_exchanges).toEqual [
|
||||
{enterprise_id: "2", active: true}
|
||||
]
|
||||
expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual [
|
||||
{enterprise_id: "4", active: true}
|
||||
{enterprise_id: "6", active: true}
|
||||
]
|
||||
|
||||
|
||||
describe 'OrderCycle directives', ->
|
||||
|
||||
Reference in New Issue
Block a user