Translator accepts array

This commit is contained in:
Vit Brunner
2013-06-17 18:46:16 +01:00
parent 8bfbb29e9f
commit c38b7e57cd
2 changed files with 7 additions and 7 deletions
@@ -1,10 +1,10 @@
angular.module("sideBySide").factory("transformer", () ->
# Transform translations
#
# @param translations [...Object] Translation with 'meta' and 'content' keys
# @param translations [Array] Translations with 'meta' and 'content' keys
# @throw No poems or uneven number of verses
# @return [Array] Translations transformed into row-based format
return (translations...) ->
return (translations) ->
# Check whether all translations have same number of verses
#
# @param translations [array] Translations to check
@@ -94,14 +94,14 @@ test("transformer", () ->
# Test transformation works as it should
transformer = injector.get("transformer")
deepEqual(transformer(english, czech, polish), expected)
deepEqual(transformer([english, czech, polish]), expected)
# Test transformation still works when we remove Polish
expected.meta = expected.meta.slice(0, 2)
expected.verses = _.map(expected.verses, (translations) ->
return translations.slice(0, 2)
)
deepEqual(transformer(english, czech), expected)
deepEqual(transformer([english, czech]), expected)
# Test various error messages
throws(() ->
@@ -110,16 +110,16 @@ test("transformer", () ->
czech.content.pop()
throws(() ->
transformer(english, czech, polish)
transformer([english, czech, polish])
, /missing.*nevezmeš jména/i)
polish.content.pop()
throws(() ->
transformer(english, czech, polish)
transformer([english, czech, polish])
, /superfluous.*sabbath/i)
polish.content.pop()
throws(() ->
transformer(english, czech, polish)
transformer([english, czech, polish])
, /missing.*bogów cudzych.*nevezmeš/i)
)