mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-06 02:51:34 +00:00
adding by producer id filtering
This commit is contained in:
committed by
Rohan Mitchell
parent
e858c0d434
commit
4a116570d1
@@ -0,0 +1,6 @@
|
||||
Darkswarm.filter "byProducer", ->
|
||||
(objects, id) ->
|
||||
objects ||= []
|
||||
id ?= 0
|
||||
objects.filter (obj)->
|
||||
obj.producer.id == id
|
||||
@@ -0,0 +1,21 @@
|
||||
describe 'filtering by producer', ->
|
||||
filterByProducer = null
|
||||
objects = [
|
||||
{
|
||||
producer:
|
||||
id: 1
|
||||
}
|
||||
{
|
||||
producer:
|
||||
id: 2
|
||||
}
|
||||
]
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
inject ($filter) ->
|
||||
filterByProducer = $filter('byProducer')
|
||||
|
||||
it "filters by producer", ->
|
||||
expect(filterByProducer(objects, 1)[0]).toBe objects[0]
|
||||
expect(filterByProducer(objects, 2)[0]).toBe objects[1]
|
||||
Reference in New Issue
Block a user