Write unit test for MaterialLayout

master
Alexander Surma 2015-03-17 14:56:28 +00:00
parent e1221e3e29
commit 666e660024
2 changed files with 23 additions and 0 deletions

View File

@ -46,6 +46,7 @@
<script src="../src/checkbox/checkbox.js"></script>
<script src="../src/column-layout/column-layout.js"></script>
<script src="../src/icon-toggle/icon-toggle.js"></script>
<script src="../src/layout/layout.js"></script>
<script src="../src/radio/radio.js"></script>
<script src="../src/spinner/spinner.js"></script>
<script src="../src/menu/menu.js"></script>
@ -62,6 +63,7 @@
<script src="unit/checkbox.js"></script>
<script src="unit/column-layout.js"></script>
<script src="unit/icon-toggle.js"></script>
<script src="unit/layout.js"></script>
<script src="unit/radio.js"></script>
<script src="unit/spinner.js"></script>
<script src="unit/menu.js"></script>

21
test/unit/layout.js Normal file
View File

@ -0,0 +1,21 @@
describe('layout tests', function () {
it('Should have MaterialLayout globally available', function () {
expect(MaterialLayout).to.be.a('function');
});
it('Should be upgraded to a MaterialLayout successfully', function () {
var el = document.createElement('div');
el.innerHTML = '<div class="wsk-layout__header"></div>' +
'<div class="wsk-layout__drawer"></div>' +
'<div class="wsk-layout__content"></div>';
var parent = document.createElement('div');
parent.appendChild(el); // MaterialLayout.init() expects a parent
componentHandler.upgradeElement(el, 'MaterialLayout');
var upgraded = el.getAttribute('data-upgraded');
expect(upgraded).to.contain('MaterialLayout');
});
});