Transformer error on empty list

This commit is contained in:
Vit Brunner
2013-06-16 10:53:29 +01:00
parent a45c94189a
commit 9e2f937466
2 changed files with 8 additions and 2 deletions
@@ -2,13 +2,15 @@ angular.module("sideBySide").factory("transformer", () ->
# Transform translations
#
# @param translations [...Object] Translation with 'meta' and 'content' keys
# @throw On uneven number of verses
# @throw No poems or uneven number of verses
# @return [Array] Translations transformed into row-based format
return (translations...) ->
# Check whether all translations have same number of verses
#
# @param translations [array] Translations to check
check_lengths = (translations) ->
if translations.length < 1
throw "No poems found!"
lengths = []
for translation in translations
l = translation.content.length
@@ -103,7 +103,11 @@ test("transformer", () ->
)
deepEqual(transformer(english, czech), expected)
# Test various error messages as we remove items
# Test various error messages
throws(() ->
transformer()
)
czech.content.pop()
throws(() ->
transformer(english, czech, polish)