Add inactive getter to poems

This commit is contained in:
Vit Brunner
2014-12-20 21:03:48 +01:00
parent dd86ab40b6
commit 26032b4410
2 changed files with 19 additions and 6 deletions
+6
View File
@@ -17,6 +17,12 @@ angular.module("sideBySide").service "poems", ['fetch', 'route', (fetch, route)
@getActive = () ->
(poem for poem in @all when poem.meta.Active is true)
# Get inactive poems
#
# @return [Array] Inactive poems
@getInactive = () ->
(poem for poem in @all when poem.meta.Active is not true)
# Activize poem based on passed rules
#
# @param poem [Object]
+13 -6
View File
@@ -8,12 +8,7 @@ module "poems", {
poems = angular.injector(['ng', 'sideBySide']).get('poems')
}
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", () ->
setPoems = () ->
poems.all = [{
meta: { Active: true }
content: [{ section: '1', text: 'one' }]
@@ -25,6 +20,18 @@ test "gets active", () ->
content: [{ section: '3', text: 'three' }]
}]
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", () ->
setPoems()
active = poems.getActive()
equal active[0].content[0].section, '1'
equal active[1].content[0].section, '3'
test "gets inactive", () ->
setPoems()
inactive = poems.getInactive()
equal inactive[0].content[0].section, '2'