siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
65 lines (47 loc) • 1.64 kB
JavaScript
Class('Your.Test.Class', {
isa : Siesta.Test.Browser,
// include mixins if needed (for better codebase organization)
does : [
Your.Test.Role
],
has : {
// will be initialized with atomic values
attribute1 : null,
attribute2 : 'foo',
attribute3 : 11,
attribute4 : {
// will be initialized with { foo : 'bar' } object
init : { foo : 'bar' }
},
attribute41 : function () {
// will be initialized with the returning value of the function
return { some : 'thing' }
},
// will be initialized with empty array
attribute5 : Joose.I.Array,
// will be initialized with empty object
attribute6 : Joose.I.Object
},
methods: {
// example of asynchronous tear down process, one can be asynchronous requests here, etc
tearDown : function (callback, errback) {
setTimeout(function () {
callback()
}, 100)
},
// helper method
getButton : function (text, onClick) {
var button = document.createElement('input')
button.type = 'button'
button.value = text
onClick && button.addEventListener('click', onClick)
return button
},
// another helper method
addButtonToBody : function (text, onClick) {
var button = this.getButton(text, onClick)
document.body.addChild(button)
return button
}
}
});