mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-31 21:37:16 +00:00
Adding all the Angular filters required to make this work
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
describe 'filtering by active', ->
|
||||
filterByActive = null
|
||||
objects = [
|
||||
{
|
||||
active: true
|
||||
}
|
||||
{
|
||||
active: false
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
inject ($filter) ->
|
||||
filterByActive = $filter('active')
|
||||
|
||||
it "filters to active", ->
|
||||
expect(filterByActive(objects, {closed: false, open: true})[0]).toBe objects[0]
|
||||
|
||||
it "filters to inactive", ->
|
||||
expect(filterByActive(objects, {closed: true, open: false})[0]).toBe objects[1]
|
||||
|
||||
it "doesn't filter if needed", ->
|
||||
expect(filterByActive(objects, {closed: false, open: false})).toBe objects
|
||||
|
||||
it "filters to all", ->
|
||||
expect(filterByActive(objects, {closed: true, open: true})).toBe objects
|
||||
@@ -0,0 +1,30 @@
|
||||
describe 'filtering by shipping method', ->
|
||||
filterByShippingMethod = null
|
||||
objects = [
|
||||
{
|
||||
delivery: true
|
||||
pickup: false
|
||||
}
|
||||
{
|
||||
delivery: false
|
||||
pickup: true
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
inject ($filter) ->
|
||||
filterByShippingMethod = $filter('shipping')
|
||||
|
||||
it "filters to pickup", ->
|
||||
expect(filterByShippingMethod(objects, {pickup: true, delivery: false})[0]).toBe objects[1]
|
||||
|
||||
it "filters to delivery", ->
|
||||
expect(filterByShippingMethod(objects, {pickup: false, delivery: true})[0]).toBe objects[0]
|
||||
|
||||
it "filters to both", ->
|
||||
expect(filterByShippingMethod(objects, {pickup: true, delivery: true})).toBe objects
|
||||
|
||||
it "filters to none", ->
|
||||
expect(filterByShippingMethod(objects, {pickup: false, delivery: false})).toBe objects
|
||||
@@ -0,0 +1,27 @@
|
||||
describe 'filtering by taxons', ->
|
||||
filterByTaxons = null
|
||||
objects = [
|
||||
{
|
||||
taxons: []
|
||||
primary_taxon:
|
||||
name: "frogs"
|
||||
}
|
||||
{
|
||||
taxons: [
|
||||
{name: "kittens"}
|
||||
{name: "puppies"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
inject ($filter) ->
|
||||
filterByTaxons = $filter('taxons')
|
||||
|
||||
it "filters by primary taxon", ->
|
||||
expect(filterByTaxons(objects, "frogs")[0]).toBe objects[0]
|
||||
|
||||
it "filters by taxons", ->
|
||||
expect(filterByTaxons(objects, "kittens")[0]).toBe objects[1]
|
||||
Reference in New Issue
Block a user