mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-03 06:59:14 +00:00
Flag enterprises whose name matches a query
This commit is contained in:
@@ -17,14 +17,14 @@ describe "Enterprises service", ->
|
||||
{id: 1, name: "test"}
|
||||
]
|
||||
enterprises = [
|
||||
{id: 1, visible: true, category: "hub", producers: [{id: 5}], taxons: [{id: 1}]},
|
||||
{id: 2, visible: true, category: "hub", producers: [{id: 6}]}
|
||||
{id: 3, visible: true, category: "hub_profile"}
|
||||
{id: 4, visible: false, category: "hub", producers: [{id: 7}]}
|
||||
{id: 5, visible: true, category: "producer_hub", hubs: [{id: 1}]},
|
||||
{id: 6, visible: true, category: "producer_shop", hubs: [{id: 2}]},
|
||||
{id: 7, visible: true, category: "producer", hubs: [{id: 2}]}
|
||||
{id: 8, visible: false, category: "producer", hubs: [{id: 2}]}
|
||||
{id: 1, visible: true, name: 'a', category: "hub", producers: [{id: 5}], taxons: [{id: 1}]},
|
||||
{id: 2, visible: true, name: 'b', category: "hub", producers: [{id: 6}]}
|
||||
{id: 3, visible: true, name: 'c', category: "hub_profile"}
|
||||
{id: 4, visible: false,name: 'd', category: "hub", producers: [{id: 7}]}
|
||||
{id: 5, visible: true, name: 'e', category: "producer_hub", hubs: [{id: 1}]},
|
||||
{id: 6, visible: true, name: 'f', category: "producer_shop", hubs: [{id: 2}]},
|
||||
{id: 7, visible: true, name: 'g', category: "producer", hubs: [{id: 2}]}
|
||||
{id: 8, visible: false,name: 'h', category: "producer", hubs: [{id: 2}]}
|
||||
]
|
||||
H1: 0
|
||||
beforeEach ->
|
||||
@@ -87,6 +87,20 @@ describe "Enterprises service", ->
|
||||
expect(Enterprises.producers).toContain Enterprises.enterprises[5]
|
||||
expect(Enterprises.producers).toContain Enterprises.enterprises[6]
|
||||
|
||||
describe "flagging enterprises with names matching a query", ->
|
||||
it "flags enterprises when a query is provided", ->
|
||||
Enterprises.flagMatching 'c'
|
||||
expect(e.matches_name_query).toBe true for e in enterprises when e.name == 'c'
|
||||
expect(e.matches_name_query).toBe false for e in enterprises when e.name != 'c'
|
||||
|
||||
it "clears flags when query is null", ->
|
||||
Enterprises.flagMatching null
|
||||
expect(e.matches_name_query).toBe false for e in enterprises
|
||||
|
||||
it "clears flags when query is blank", ->
|
||||
Enterprises.flagMatching ''
|
||||
expect(e.matches_name_query).toBe false for e in enterprises
|
||||
|
||||
describe "updating distance of enterprises from a location", ->
|
||||
it "calculates the distance when a query is provided", ->
|
||||
spyOn(Enterprises, "calculateDistance")
|
||||
|
||||
Reference in New Issue
Block a user