mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Tests and patch for group filter
This commit is contained in:
@@ -5,6 +5,6 @@ Darkswarm.filter "groups", (Matcher)->
|
||||
|
||||
groups.filter (group)=>
|
||||
Matcher.match([
|
||||
group.name, group.description, group.long_description
|
||||
group.name, group.long_description
|
||||
], text) || group.enterprises.some (e)->
|
||||
Matcher.match [e.name], text
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
describe "filtering Groups", ->
|
||||
filterGroups = null
|
||||
groups = [{
|
||||
name: "test"
|
||||
long_description: "roger"
|
||||
enterprises: [{
|
||||
name: "kittens"
|
||||
}, {
|
||||
name: "kittens"
|
||||
}]
|
||||
}, {
|
||||
name: "blankness"
|
||||
long_description: "in the sky"
|
||||
enterprises: [{
|
||||
name: "ponies"
|
||||
}, {
|
||||
name: "ponies"
|
||||
}]
|
||||
}
|
||||
]
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
inject ($filter) ->
|
||||
filterGroups = $filter('groups')
|
||||
|
||||
it "filters by name", ->
|
||||
expect(filterGroups(groups, "test")[0]).toBe groups[0]
|
||||
|
||||
it "filters by description", ->
|
||||
expect(filterGroups(groups, "sky")[0]).toBe groups[1]
|
||||
|
||||
it "filters by enterprise name", ->
|
||||
expect(filterGroups(groups, "ponies")[0]).toBe groups[1]
|
||||
Reference in New Issue
Block a user