siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
132 lines (100 loc) • 4.2 kB
HTML
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
<style type="text/css">
.highlight { display: block; background-color: #ddd; }
</style>
<script type="text/javascript">
function highlight() {
document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
}
</script>
</head>
<body onload="prettyPrint(); highlight();">
<pre class="prettyprint lang-js">/*
Siesta 5.6.1
Copyright(c) 2009-2022 Bryntum AB
https://bryntum.com/contact
https://bryntum.com/products/siesta/license
*/
Ext.define('Siesta.Project.Browser.Model.TestFile', {
extend : 'Ext.data.Model',
idProperty : 'id',
fields : [
'id',
'url',
'title',
'tooltip',
{ name : 'passCount', type : 'int', defaultValue : 0 },
{ name : 'failCount', type : 'int', defaultValue : 0 },
{ name : 'todoPassCount', type : 'int', defaultValue : 0 },
{ name : 'todoFailCount', type : 'int', defaultValue : 0 },
{ name : 'time', type : 'int', defaultValue : 0 },
{ name : 'checked', defaultValue : false },
{ name : 'folderStatus', defaultValue : 'yellow' },
// will be set to true for all tests, once the users clicks "run"
'isStarting',
// will be set to true, after preload ends and tests launch
{ name : 'isRunning', type : 'boolean', defaultValue : false },
{ name : 'isMissing', type : 'boolean', defaultValue : false },
{ name : 'isFailed', type : 'boolean', defaultValue : false },
// composite objects
'assertionsStore',
'test',
'descriptor'
],
//init : function () {
//this.internalId = this.getId() || this.internalId
//debugger;
//},
computeFolderStatus : function () {
if (!this.childNodes.length) return 'yellow'
var isWorking = false
var hasFailed = false
var allGreen = true
Joose.A.each(this.childNodes, function (childNode) {
if (childNode.isLeaf()) {
var test = childNode.get('test')
if (test && test.isFailed()) {
allGreen = false
hasFailed = true
// stop iteration
return false
}
if (!test && childNode.get('isStarting')) isWorking = true
if (test && !test.isFinished()) isWorking = true
if (test && !test.isPassed()) allGreen = false
if (!test) allGreen = false
} else {
var status = childNode.computeFolderStatus()
if (status == 'red') {
allGreen = false
hasFailed = true
// stop iteration
return false
}
if (status == 'working') {
isWorking = true
// stop iteration
return false
}
if (status == 'yellow') allGreen = false
}
})
if (isWorking) return 'working'
if (hasFailed) return 'red'
if (allGreen) return 'green'
return 'yellow'
},
updateFolderStatus : function () {
this.set('folderStatus', this.computeFolderStatus())
var parentNode = this.parentNode
if (parentNode && !parentNode.isRoot()) parentNode.updateFolderStatus()
}
})</pre>
</body>
</html>