@@ -2,7 +2,8 @@ var path = require('path'),
22 events = require ( 'events' ) ,
33 assert = require ( 'assert' ) ,
44 fs = require ( 'fs' ) ,
5- vows = require ( '../lib/vows' ) ;
5+ vows = require ( '../lib/vows' ) ,
6+ silent = require ( '../lib/vows/reporters/silent' ) ;
67
78function doSomethingAsync ( callback ) {
89 var err = null ;
@@ -48,4 +49,59 @@ vows.describe('vows/error').addBatch({
4849 assert . equal ( testValue , 'a' ) ;
4950 }
5051 }
51- } ) . export ( module )
52+ } ) . export ( module )
53+
54+ vows . describe ( 'Error Handling' ) . addBatch ( {
55+ "A topic with a function that errors" : {
56+ topic : function ( ) {
57+ throw ( "Something wrong here" ) ;
58+ } ,
59+ "should return an error to a vow with two parameters" : function ( e , data ) {
60+ assert . equal ( e , "Something wrong here" ) ;
61+ }
62+ } ,
63+ "A topic with a built-in error" : {
64+ topic : function ( ) {
65+ bad . bad ;
66+ } ,
67+ "should return an error to a vow with two parameters" : function ( e , data ) {
68+ assert ( e instanceof Error , "Return value " + e + " wasn't an Error." ) ;
69+ }
70+ } ,
71+ "The previous two topics run in their own suite," : {
72+ "connected to two vows expecting one argument each" : {
73+ topic : function ( ) {
74+ vows . describe ( ) . addBatch ( {
75+ "A topic with a function that errors" : {
76+ topic : function ( ) {
77+ throw ( "Something wrong here" ) ;
78+ } ,
79+ "should record the error in the test results" : function ( data ) {
80+ assert . ok ( ! data ) ;
81+ }
82+ //» An unexpected error was caught: "Something wrong here"
83+ } ,
84+ "A topic with a built-in error" : {
85+ topic : function ( ) {
86+ bad . bad ;
87+ } ,
88+ "should record the error in the test results" : function ( data ) {
89+ assert . ok ( ! data ) ;
90+ }
91+ //» An unexpected error was caught: ReferenceError: bad is not defined
92+ }
93+ } ) . run ( { reporter : silent } , this . callback ) ;
94+ } ,
95+ "should have an errored count of two" : function ( results , unused ) {
96+ assert . equal ( results . errored , 2 ) ;
97+ } ,
98+ "should have a total count of two" : function ( results , unused ) {
99+ assert . equal ( results . total , 2 ) ;
100+ } ,
101+ "should have an honored count of zero" : function ( results , unused ) {
102+ assert . equal ( results . honored , 0 ) ;
103+ }
104+ }
105+ }
106+ } ) . export ( module ) ;
107+
0 commit comments