Tests and patch for group filter

This commit is contained in:
Will Marshall
2014-06-27 15:01:12 +10:00
parent 8bd8d811b1
commit e8ba36041b
2 changed files with 35 additions and 1 deletions

View File

@@ -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

View File

@@ -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]