Fewer parentheses

This commit is contained in:
Vit Brunner
2014-12-22 23:07:40 +01:00
parent 83fbe5d538
commit fe8c134920
17 changed files with 100 additions and 108 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ filter = {}
poemList = {}
module "filter", {
setup: () ->
setup: ->
poemList.poe = { meta: {
Active: false
Author: 'Edgar Allan Poe'
@@ -47,7 +47,7 @@ module "filter", {
filter = injector.get('filter')
}
test "get filter for poems that share a common property", () ->
test "get filter for poems that share a common property", ->
poemList.dolu.meta.Active = true
poemList.vrch.meta.Active = true
poemList.muz.meta.Active = true
@@ -57,7 +57,7 @@ test "get filter for poems that share a common property", () ->
'Language': [ 'Czech' ]
}
test "get filter for arbitrary poems using shortest key", () ->
test "get filter for arbitrary poems using shortest key", ->
poemList.vrch.meta.Active = true
poemList.muz.meta.Active = true
filter.update()
+5 -5
View File
@@ -1,11 +1,11 @@
poems = {}
module "poems", {
setup: () ->
setup: ->
poems = getInjector().get 'poems'
}
setPoems = () ->
setPoems = ->
poems.all = [{
meta: { Active: true }
content: [{ section: '1', text: 'one' }]
@@ -20,18 +20,18 @@ setPoems = () ->
content: [{ section: '4', text: 'four' }]
}]
test "has default content", () ->
test "has default content", ->
active = poems.getActive()
equal active[0].content[0].text, 'Please be patient!'
equal active[0].content[0].section, 'Loading...'
test "gets active", () ->
test "gets active", ->
setPoems()
active = poems.getActive()
equal active[0].content[0].section, '1'
equal active[1].content[0].section, '3'
test "gets inactive", () ->
test "gets inactive", ->
setPoems()
inactive = poems.getInactive()
equal inactive[0].content[0].section, '2'
@@ -1,18 +1,18 @@
factory = {}
module "reader factory", {
setup: () ->
setup: ->
factory = getInjector().get 'readerFactory'
}
test "reads markdown", () ->
test "reads markdown", ->
ok factory "somefile.md"
ok factory "otherfile.markdown"
test "reads json", () ->
test "reads json", ->
ok factory "fried.json"
test "doesn't read doc", () ->
throws () ->
test "doesn't read doc", ->
throws ->
factory "microsoft.doc"
, /unknown/i
+2 -2
View File
@@ -1,11 +1,11 @@
reader = {}
module "json reader", {
setup: () ->
setup: ->
reader = getInjector().get 'jsonReader'
}
test "loads poem", () ->
test "loads poem", ->
deepEqual reader("""
{
meta: {
@@ -1,11 +1,11 @@
reader = {}
module "markdown reader", {
setup: () ->
setup: ->
reader = getInjector().get 'markdownReader'
}
test "loads poem with section numbers, paragraphs, and a list", () ->
test "loads poem with section numbers, paragraphs, and a list", ->
deepEqual reader("""
Title: Universal Declaration of Human Rights
Author: John Peters Humphrey
@@ -57,7 +57,7 @@ test "loads poem with section numbers, paragraphs, and a list", () ->
]
}
test "loads poem with leading text and mixed separators", () ->
test "loads poem with leading text and mixed separators", ->
deepEqual reader("""
Title: Test leading text and mixed separators
@@ -79,7 +79,7 @@ test "loads poem with leading text and mixed separators", () ->
]
}
test "loads poem using a custom separator", () ->
test "loads poem using a custom separator", ->
deepEqual reader("""
Title: Separator test
Separator: heading
+10 -10
View File
@@ -7,33 +7,33 @@ setup = (
path = '/base:asdf/section:7'
hash = '#test'
) ->
angular.module("sideBySide").service("$location", () ->
@path = () -> path
@url = () -> path + hash
@absUrl = () -> base + path + hash
angular.module("sideBySide").service("$location", ->
@path = -> path
@url = -> path + hash
@absUrl = -> base + path + hash
@
)
route = getInjector().get 'route'
test "has app url", () ->
test "has app url", ->
setup()
equal route.appUrl, 'http://example.com'
test "gets parameters", () ->
test "gets parameters", ->
setup()
equal route.get(), 'base:asdf/section:7'
test "updates parameters", () ->
test "updates parameters", ->
setup()
route.update('base', 'zxcv')
equal route.get(), 'base:zxcv/section:7'
test "adds parameter", () ->
test "adds parameter", ->
setup('http://example.com', '/base:asdf')
route.update('section', '1')
equal route.get(), 'base:asdf/section:1'
test "processes arrays from url", () ->
test "processes arrays from url", ->
setup('http://example.com', '/display:Language:Czech,English', '')
deepEqual route.params, {
@@ -43,7 +43,7 @@ test "processes arrays from url", () ->
}
}
test "adds base before section", () ->
test "adds base before section", ->
setup('http://example.com', '/section:7', '')
route.update('base', 'the_raven')
equal route.get(), 'base:the_raven/section:7'
+13 -13
View File
@@ -5,7 +5,7 @@ polish = {}
expected = {}
module "transformer", {
setup: () ->
setup: ->
transformer = getInjector().get 'transformer'
english = {
@@ -58,43 +58,43 @@ module "transformer", {
}
}
test "transforms", () ->
test "transforms", ->
deepEqual transformer([english, czech, polish]), expected
test "transforms with 2 items", () ->
test "transforms with 2 items", ->
expected.meta = expected.meta.slice(0, 2)
expected.verses = _.map(expected.verses, (translations) ->
return translations.slice(0, 2)
)
deepEqual transformer([english, czech]), expected
test "throws error on no param", () ->
throws () ->
test "throws error on no param", ->
throws ->
transformer()
, /no poems found/i
test "throws error on empty array", () ->
throws () ->
test "throws error on empty array", ->
throws ->
transformer []
, /no poems found/i
test "throws error on poem being too short", () ->
test "throws error on poem being too short", ->
czech.content.pop()
throws () ->
throws ->
transformer [english, czech, polish]
, /missing.*nevezmeš jména/i
test "throws error on poem being too long", () ->
test "throws error on poem being too long", ->
czech.content.pop()
polish.content.pop()
throws () ->
throws ->
transformer [english, czech, polish]
, /superfluous.*sabbath/i
test "throws error on poems too short plus different lengths", () ->
test "throws error on poems too short plus different lengths", ->
czech.content.pop()
polish.content.pop()
polish.content.pop()
throws () ->
throws ->
transformer [english, czech, polish]
, /missing.*bogów cudzych.*nevezmeš/i