Created
August 30, 2013 18:11
-
-
Save SimplGy/fce4d59a7e46467ea7dc to your computer and use it in GitHub Desktop.
Favorite unit test yet :)
Uses a loop over a hash to test expectations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define [ | |
'./circles' | |
], | |
( | |
Circles | |
) -> | |
_data = [ | |
{ size: 2 } | |
{ size: 2 } | |
{ size: 2 } | |
{ size: 2 } | |
{ size: 2 } | |
] | |
_szPercentMappings = | |
'0': 0 | |
'10': 0 | |
'19': 0 | |
'20': 1 | |
'39': 1 | |
'40': 2 | |
'50': 2 | |
'59': 2 | |
'70': 3 | |
'90': 4 | |
'99': 4 | |
'100': 4 | |
describe 'entities/circles', -> | |
circles = null | |
beforeEach -> circles = new Circles _data | |
it 'exists', -> expect(circles).toBeDefined() | |
it 'is instantiated with data', -> expect(circles.length).toEqual _data.length | |
describe '_setSizeByPercent', -> | |
circle = null | |
beforeEach -> circle = circles.at(0) | |
it 'is defined', -> expect(circle._setSizeByPercent).toBeDefined() | |
it 'calculates expected sizes', -> | |
for key, val of _szPercentMappings | |
expect(circle._setSizeByPercent(key).get('size')).toEqual _szPercentMappings[key] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment