diff --git a/source/documents/scripts/services/transformer.js.coffee b/source/documents/scripts/services/transformer.js.coffee index 154bbdb..9daf9d7 100644 --- a/source/documents/scripts/services/transformer.js.coffee +++ b/source/documents/scripts/services/transformer.js.coffee @@ -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 diff --git a/source/documents/tests/services/transformer.js.coffee b/source/documents/tests/services/transformer.js.coffee index 436e82d..27707ca 100644 --- a/source/documents/tests/services/transformer.js.coffee +++ b/source/documents/tests/services/transformer.js.coffee @@ -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)