Refactor filter test

This commit is contained in:
Vit Brunner
2015-01-06 16:12:38 +01:00
parent 750f30189b
commit 437dacd75b
+44 -39
View File
@@ -1,53 +1,57 @@
poems = {}
filter = {}
poemList = {}
module "filter", {
setup: ->
poemList.poe = { meta: {
Active: false
Author: 'Edgar Allan Poe'
Title: 'The Raven'
Year: '1845'
Language: 'English'
Code: 'poe'
}}
poemList.vrch = { meta: {
Active: false
Author: 'Jaroslav Vrchlický'
Title: 'Havran'
Year: '1845'
Language: 'Czech'
Code: 'vrch'
}}
poemList.muz = { meta: {
Active: false
Author: 'Augustin Eugen Mužík'
Title: 'Havran'
Year: '1885'
Language: 'Czech'
Code: 'muz'
}}
poemList.dolu = { meta: {
Active: false
Author: 'Karel Dostál Lutinov'
Title: 'Havran'
Year: '1918'
Language: 'Czech'
Code: 'dolu'
}}
injector = getInjector()
poems = injector.get('poems')
poems.all = [
poemList.poe
poemList.vrch
poemList.muz
poemList.dolu
]
filter = injector.get('filter')
}
setPoems = ->
poemList.poe = { meta: {
Active: false
Author: 'Edgar Allan Poe'
Title: 'The Raven'
Year: '1845'
Language: 'English'
Code: 'poe'
}}
poemList.vrch = { meta: {
Active: false
Author: 'Jaroslav Vrchlický'
Title: 'Havran'
Year: '1845'
Language: 'Czech'
Code: 'vrch'
}}
poemList.muz = { meta: {
Active: false
Author: 'Augustin Eugen Mužík'
Title: 'Havran'
Year: '1885'
Language: 'Czech'
Code: 'muz'
}}
poemList.dolu = { meta: {
Active: false
Author: 'Karel Dostál Lutinov'
Title: 'Havran'
Year: '1918'
Language: 'Czech'
Code: 'dolu'
}}
poems.all = [
poemList.poe
poemList.vrch
poemList.muz
poemList.dolu
]
test "get filter for poems that share a common property", ->
setPoems()
poemList.dolu.meta.Active = true
poemList.vrch.meta.Active = true
poemList.muz.meta.Active = true
@@ -58,6 +62,7 @@ test "get filter for poems that share a common property", ->
}
test "get filter for arbitrary poems using shortest key", ->
setPoems()
poemList.vrch.meta.Active = true
poemList.muz.meta.Active = true
filter.update()