mirror of
https://github.com/wassname/side-by-side.git
synced 2026-09-09 11:34:24 +08:00
Translator accepts array
This commit is contained in:
@@ -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)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user