Created
February 18, 2012 16:57
-
-
Save arian/1860182 to your computer and use it in GitHub Desktop.
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
describe('getStyle height / width / margin with CSS', function(){ | |
var style, element; | |
it('[beforeAll]', function(){ | |
var className = String.uniqueID(); | |
style = $(document.createElement('style')); | |
style.type = 'text/css'; | |
var definition = [ | |
'.' + className + '{', | |
'height: 200px;', | |
'width: 50%;', | |
'margin-left: 20%;', | |
'}' | |
].join(''); | |
// fix this, see https://github.com/mootools/mootools-core/issues/2265 | |
if (style.styleSheet) style.styleSheet.cssText = definition; | |
else style.set('text', definition); | |
document.head.appendChild(style); | |
element = new Element('div', { | |
'class': className, | |
text: 'yo' | |
}).inject(document.body); | |
}); | |
it('should get the height from the CSS', function(){ | |
expect(element.getStyle('height')).toEqual('200px'); | |
}); | |
it('should get the width from the CSS', function(){ | |
expect(element.getStyle('width')).toMatch(/\d+px/); | |
}); | |
it('should get the left margin from the CSS', function(){ | |
expect(element.getStyle('margin-left')).toEqual('20%'); | |
}); | |
it('[afterAll]', function(){ | |
style.destroy(); | |
element.destroy(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment