mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-02 21:57:17 +00:00
Improve and unit test errorsParser
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
describe "ErrorsParser service", ->
|
||||
errorsParser = null
|
||||
|
||||
beforeEach ->
|
||||
module('admin.utils')
|
||||
inject (ErrorsParser) ->
|
||||
errorsParser = ErrorsParser
|
||||
|
||||
describe "toString", ->
|
||||
it "returns empty string for nil errors", ->
|
||||
expect(errorsParser.toString(null)).toEqual ""
|
||||
|
||||
it "returns the elements in the array if an array is provided", ->
|
||||
expect(errorsParser.toString(["1", "2"])).toEqual "1\n2\n"
|
||||
|
||||
it "returns the elements in the hash if a hash is provided", ->
|
||||
expect(errorsParser.toString({ "keyname": ["1", "2"] })).toEqual "1\n2\n"
|
||||
|
||||
it "returns all elements in all hash keys provided", ->
|
||||
expect(errorsParser.toString({ "keyname1": ["1", "2"], "keyname2": ["3", "4"] })).toEqual "1\n2\n3\n4\n"
|
||||
Reference in New Issue
Block a user