mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-15 23:57:48 +00:00
Fix taxon service specs
This commit is contained in:
27
spec/javascripts/unit/admin/services/taxons_spec.js.coffee
Normal file
27
spec/javascripts/unit/admin/services/taxons_spec.js.coffee
Normal file
@@ -0,0 +1,27 @@
|
||||
describe "Taxons service", ->
|
||||
Taxons = taxons = $httpBackend = $resource = null
|
||||
|
||||
beforeEach ->
|
||||
module "ofn.admin"
|
||||
module ($provide)->
|
||||
$provide.value "taxons", [{id: "1", name: "t1"}, {id: "2", name: "t2"}, {id: "12", name: "t12"}, {id: "31", name: "t31"}]
|
||||
null
|
||||
|
||||
beforeEach inject (_Taxons_, _$resource_, _$httpBackend_) ->
|
||||
Taxons = _Taxons_
|
||||
$resource = _$resource_
|
||||
$httpBackend = _$httpBackend_
|
||||
|
||||
describe "calling findByIDs", ->
|
||||
it "returns taxons with exactly matching ids", ->
|
||||
result = Taxons.findByIDs("1,2")
|
||||
expect(result).toEqual [{id: "1", name: "t1"}, {id: "2", name: "t2"}]
|
||||
|
||||
it "ignores ids which do not exactly match", ->
|
||||
result = Taxons.findByIDs("1,3")
|
||||
expect(result).toEqual [{id: "1", name: "t1"}]
|
||||
|
||||
describe "calling findByTerm", ->
|
||||
it "returns taxons which match partially", ->
|
||||
result = Taxons.findByTerm("t1")
|
||||
expect(result).toEqual [{id: "1", name: "t1"}, {id: "12", name: "t12"}]
|
||||
Reference in New Issue
Block a user