Comparing version 5.1.9 to 5.1.10
@@ -82,2 +82,3 @@ "use strict"; | ||
group.parentGroup.title.passed++ | ||
group.parentGroup.updateTitle() | ||
} | ||
@@ -268,8 +269,8 @@ | ||
$state: function(state) { | ||
if(state.late) { | ||
if(!state.success) { | ||
var textColor = color.red | ||
} else if(state.late) { | ||
var textColor = color.yellow | ||
} else if(state.success) { | ||
} else { | ||
var textColor = color.green | ||
} else { | ||
var textColor = color.red | ||
} | ||
@@ -353,2 +354,3 @@ | ||
updateCountSuccess(this) // must be run before updateTitle (because it modifies info updateTitle relies on) | ||
this.updateTitle() | ||
@@ -371,2 +373,3 @@ } | ||
updateCountSuccess(this) // must be run before updateTitle (because it modifies info updateTitle relies on) | ||
this.updateTitle() | ||
@@ -391,2 +394,3 @@ } | ||
updateCountSuccess(this) // must be run before updateTitle (because it modifies info updateTitle relies on) | ||
this.updateTitle() | ||
@@ -396,15 +400,6 @@ } | ||
this.end = function(time) { | ||
// figure out if count succeeded | ||
if(this.expected !== undefined) { | ||
var countSuccess = this.count === this.expected | ||
this.countBlock.state.set("success", countSuccess) | ||
//updateCountSuccess(this, true) // must be run before groupEnded is set (because it relies on groupEnded being false at this point) | ||
if(this.expected !== undefined && !(this.count === this.expected)) this.mainGroup.title.testTotalFailures++ | ||
if(countSuccess) { | ||
this.mainGroup.title.testTotalPasses++ | ||
this.title.passed++ | ||
} else { | ||
this.mainGroup.title.testTotalFailures++ | ||
} | ||
} | ||
this.groupEnded = true | ||
this.updateTitle() | ||
@@ -431,5 +426,29 @@ if(!(this instanceof MainGroup)) { | ||
}) | ||
if(this.parentGroup !== undefined) this.parentGroup.updateTitle() | ||
} | ||
}) | ||
// figure out if count succeeded and update the main group and the countblock state | ||
function updateCountSuccess(that) { | ||
if(that.expected !== undefined) { | ||
var countSuccess = that.count === that.expected | ||
that.countBlock.state.set("success", countSuccess) | ||
if(that.groupEnded) that.countBlock.results.state.set("late", true) | ||
if(countSuccess) { | ||
that.mainGroup.title.testTotalPasses++ | ||
that.title.passed++ | ||
if(that.groupEnded) { | ||
that.mainGroup.title.testTotalFailures-- | ||
that.groupEndCountSubtracted = true // marks that failures were subtracted after the test finished (so successes can be later subtracted correctly if need be) | ||
} | ||
} else if(that.groupEndCountSubtracted) { | ||
that.mainGroup.title.testTotalFailures++ | ||
that.mainGroup.title.testTotalPasses-- | ||
that.title.passed-- | ||
} | ||
} | ||
} | ||
var MainGroup = proto(Group, function(superclass) { | ||
@@ -449,2 +468,3 @@ this.name = "MainGroup" | ||
this.addAt(0, mainTitle) | ||
this.add(this.pendingText=Text("Pending...")) | ||
@@ -460,4 +480,6 @@ mainTitle.on('click', function() { | ||
this.pendingText.visible = false | ||
this.updateTitle() | ||
this.testTotalTime = getTimeDisplay(time - this.startTime) | ||
this.title.takenText.text = "Took " | ||
this.ended = true | ||
@@ -535,3 +557,3 @@ } | ||
Container('exceptions', this.testTotalExceptionsNode, Text(" exception"), this.testTotalExceptionsPlural), Text(". "), | ||
Container('time', Text("Took "), this.testTotalTimeNode, Text(".")), | ||
Container('time', this.takenText=Text("Has taken "), this.testTotalTimeNode, Text(".")), | ||
Container('clickText', Text("click on this bar")) | ||
@@ -597,2 +619,7 @@ ) | ||
var that = this | ||
this.state.on('change', function() { | ||
that.results.expectedAndActual.visible = !that.state.subject.success | ||
}) | ||
this.state.set("success", success) | ||
@@ -659,186 +686,1 @@ this.results.state.set("success", success) | ||
} | ||
/* | ||
color: '+gray+';\ | ||
}\ | ||
.resultsArea{\ | ||
margin:1px;\ | ||
margin-bottom: 5px;\ | ||
}\ | ||
.resultsAreaInner{\ | ||
padding:0 8px;\ | ||
}\ | ||
.resultsBar{\ | ||
color:white;\ | ||
margin-bottom:4px;\ | ||
padding: 1px 3px;\ | ||
}\ | ||
.testResultsArea{\ | ||
padding:0 8px;\ | ||
}\ | ||
.testResultsBar{\ | ||
background-color:'+black+';color:white;margin:4px 0;\ | ||
}\ | ||
.testResultsBarInner{\ | ||
color:white;margin:1px;padding: 1px 3px;\ | ||
}\ | ||
\ | ||
group: function(name, totalDuration, testSuccesses, testFailures, | ||
assertSuccesses, assertFailures, exceptions, | ||
testResults, exceptionResults, nestingLevel, timedOut) { | ||
var total = testSuccesses+testFailures | ||
var mainId = getMainId(name) | ||
if(testFailures > 0 || exceptions > 0) { | ||
var bgcolor=red; | ||
var show = "true"; | ||
var foregroundColor = lightRed | ||
} else { | ||
var bgcolor=green; | ||
var show = "false"; | ||
var foregroundColor = brightGreen | ||
} | ||
var durationText = timeText(totalDuration) | ||
if(nestingLevel === 0) { | ||
var initTestGroup = function(mainId, bgcolor, show) { | ||
$(function() | ||
{ $('#'+mainId).css({"border-color":"'+bgcolor+'"}); | ||
TestDisplayer.onToggle(show, bgcolor, '#'+mainId); | ||
$('#'+mainId+'_final').click(function() | ||
{ TestDisplayer.onToggle($('#'+mainId).css("display") == "none", bgcolor, '#'+mainId); | ||
}); | ||
}); | ||
} | ||
var nameLine = "", titleLine = '' | ||
if(name) { | ||
titleLine = '<h1 class="primaryTitle">'+name+'</h1>' | ||
nameLine = name+' - ' | ||
} | ||
var timeoutNote = "" | ||
if(timedOut) { | ||
timeoutNote = 'The test timed out' | ||
} | ||
return titleLine+ | ||
'<div class="testResultsArea" id="'+mainId+'">'+ | ||
testResults.join('\n')+ | ||
exceptionResults.join('\n')+"\n"+ | ||
'<div style="color:'+red+'">'+timeoutNote+'</div>'+ | ||
'</div>'+ | ||
'<div class="testResultsBar link" style="border:2px solid '+bgcolor+';" id="'+mainId+'_final">'+ | ||
'<div class="testResultsBarInner" style="background-color:'+bgcolor+';">'+ | ||
'<div style="float:right;"><i>click on this bar</i></div>'+ | ||
'<div><span class="testResultsName">'+nameLine+'</span>' + testSuccesses+'/'+total+' successful tests. '+ | ||
'<span style="color:'+brightGreen+'">'+assertSuccesses+' pass'+plural(assertSuccesses,"es","")+'</span>'+ | ||
', <span style="color:'+darkRed+'">'+assertFailures+' fail'+plural(assertFailures)+'</span>'+ | ||
', and <span style="color:'+brightPurple+'">'+exceptions+' exception'+plural(exceptions)+'</span>'+ | ||
'. <span style="color: '+white+'">Took '+durationText+".</span>"+ | ||
'</div>'+ | ||
'</div>'+ | ||
'<script>;('+initTestGroup+')("'+mainId+'", "'+bgcolor+'", '+show+')</script>'+ | ||
'</div>' | ||
} else { | ||
var n = getNewNumber() | ||
var testId = mainId+n | ||
var initTest = function(mainId, bgcolor, show, n) { | ||
$(function() | ||
{ $('#'+mainId).css({borderColor:bgcolor}); | ||
TestDisplayer.onToggle(show, bgcolor, '#'+mainId+n+'_inner', '#'+mainId+n); | ||
$('.'+mainId+n+'_status').click(function() | ||
{ TestDisplayer.onToggle | ||
( $('#'+mainId+n+'_inner').css("display") == "none", | ||
bgcolor, | ||
'#'+mainId+n+'_inner', | ||
'#'+mainId+n+'' | ||
); | ||
}); | ||
}); | ||
} | ||
if(!name) name = "<unnamed test>" | ||
return '<div class="resultsArea" id="'+mainId+n+'">'+ | ||
'<div class="resultsBar link '+mainId+n+'_status" style="background-color:'+bgcolor+';color:'+foregroundColor+'">'+ | ||
name+': '+ | ||
testSuccesses+'/'+total+" and "+exceptions+" exception"+plural(exceptions) | ||
+' <span style="color: white">took '+durationText+'</span>'+ | ||
'</div>'+ | ||
'<div class="resultsAreaInner" id="'+testId+'_inner">'+ | ||
'<h2 class="'+testId+'_status link" style="color:'+bgcolor+';">'+name+'</h2>'+ | ||
testResults.join('\n')+"\n"+ | ||
exceptionResults.join('\n')+"\n"+ | ||
'</div>'+ | ||
'<script>;('+initTest+')("'+mainId+'", "'+bgcolor+'", '+show+', '+n+')</script>'+ | ||
'</div>'; | ||
} | ||
}, | ||
assert: function(result) { | ||
if(false === result.success) { | ||
var color = red; | ||
var word = "Fail:"; | ||
} else { | ||
var color = green; | ||
var word = "Ok!"; | ||
} | ||
var linesDisplay = "<i>"+textToHtml(result.sourceLines)+"</i>"; | ||
if(result.sourceLines.indexOf("\n") !== -1) { | ||
linesDisplay = "<br>\n"+linesDisplay; | ||
} | ||
var expectations = "" | ||
if(!result.success && (result.actual !== undefined || result.expected !== undefined)) { | ||
var things = [] | ||
if(result.expected !== undefined) | ||
things.push("Expected "+textToHtml(valueToMessage(result.expected))) | ||
if(result.actual !== undefined) | ||
things.push("Got "+textToHtml(valueToMessage(result.actual))) | ||
expectations = " - "+things.join(', ') | ||
} | ||
var column = '' | ||
if(result.column !== undefined) { | ||
column = ":"+result.column | ||
} | ||
return '<div style="color:'+color+';"><span >'+word+'</span>'+ | ||
" <span class='locationOuter'>[<span class='locationInner'>" | ||
+result.file+" line <span class='lineNumber'>"+result.line+"</span>"+column+"</span>]" | ||
+"</span> " | ||
+linesDisplay | ||
+' <span class="expectations">'+expectations+'</span>' | ||
+"</div>" | ||
}, | ||
exception: function(exception) { | ||
var formattedException = textToHtml(errorToString(exception)) | ||
return '<div style="color:'+purple+';">Exception: '+formattedException+'</div>' | ||
}, | ||
log: function(values) { | ||
return '<div>' | ||
+values.map(function(v) { | ||
return textToHtml(valueToString(v)) | ||
}).join(', ') | ||
+'</div>' | ||
} | ||
*/ |
{"name":"deadunit", | ||
"description": "A dead-simple nestable unit testing library for javascript and node.js.", | ||
"keywords": ["unit", "test", "testing", "javascript", "node"], | ||
"version":"5.1.9", | ||
"version":"5.1.10", | ||
"dependencies":{ | ||
"colors":"https://github.com/fresheneesz/colors.js/archive/e990804d7c301765409770582c6aa6d562a23198.tar.gz", | ||
"deadunit-core":"5.0.15", | ||
"deadunit-core":"5.0.16", | ||
"proto":"1.0.17", | ||
@@ -9,0 +9,0 @@ "async-future":"0.1.18", |
@@ -1,2 +0,1 @@ | ||
`deadunit` | ||
@@ -199,2 +198,5 @@ ======== | ||
* Make it so that when run without a server, it emits a small note that explains that you can't get source files with the file:// protocol | ||
* add an example node http server in the docs so people can just take it and use it easily so they can get sourcelines in their test | ||
* Add tap output http://testanything.org/ | ||
@@ -242,2 +244,7 @@ * Add karma integration | ||
* 5.1.10 | ||
* fixing bug: writeHtml - Got and expected printing when the test passes | ||
* fixing bug: writeHtml - Fails aren't turning red when they're late | ||
* fixing bug: writeHtml - counts that get to their full count late A. don't turn yellow and B. the test doesn't get the count and is treated as a failure | ||
* fixing a couple other edge-case bugs in writeHtml | ||
* 5.1.9 | ||
@@ -244,0 +251,0 @@ * Removing inner titles in sub-groups in the writeHtml output |
@@ -154,2 +154,27 @@ "use strict"; | ||
.then(function() { | ||
announce("simple timeout / late successful count") | ||
options.reset() | ||
simpleTimeout = Unit.test(function(t) { | ||
this.timeout(100) | ||
this.count(1) | ||
setTimeout(function() { | ||
t.ok(true) | ||
},300) | ||
}) | ||
return printTestOutput(simpleTimeout, 'simpleTimeout', 500) | ||
}) | ||
.then(function() { | ||
announce("simple timeout / late successful then unsuccessful count") | ||
options.reset() | ||
simpleTimeout = Unit.test(function(t) { | ||
this.timeout(100) | ||
this.count(1) | ||
setTimeout(function() { | ||
t.ok(true) | ||
t.ok(true) | ||
},300) | ||
}) | ||
return printTestOutput(simpleTimeout, 'simpleTimeout', 500) | ||
}) | ||
.then(function() { | ||
announce("toString") | ||
@@ -252,3 +277,5 @@ options.reset() | ||
t.test("late test", function(t) { | ||
t.ok(true) | ||
t.test("late test innre", function(t) { | ||
t.ok(true) | ||
}) | ||
}) | ||
@@ -425,2 +452,4 @@ },500) | ||
this.test("nameless subtest", function() { | ||
// note that this subgroup itself should be empty but the unit test inside it shouldn't \/ | ||
options.reset() | ||
@@ -482,2 +511,2 @@ var test = Unit.test("nameless subtest", function() { | ||
//*/ | ||
} | ||
} |
@@ -19,8 +19,12 @@ var http = require('http'); | ||
if(path.slice(-2) === 'js') { | ||
res.setHeader("Content-Type", 'text/javascript') | ||
} | ||
res.writeHead(200) | ||
res.write(fs.readFileSync(__dirname+path)) | ||
res.end() | ||
} | ||
} catch(e) { | ||
console.log(e.message) | ||
} finally { | ||
res.end() | ||
} | ||
@@ -31,2 +35,2 @@ }) | ||
server.listen(port) | ||
console.log("listening on port "+port) | ||
console.log("listening on port "+port) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
322
1348465
13061
5
+ Addedasync-future@1.0.6(transitive)
+ Addeddeadunit-core@5.0.16(transitive)
+ Addedproto@1.0.18(transitive)
- Removedasync-future@1.0.2(transitive)
- Removeddeadunit-core@5.0.15(transitive)
- Removedproto@1.0.9(transitive)
Updateddeadunit-core@5.0.16