mirror of
https://github.com/harish2704/simple-mocha.git
synced 2026-09-10 06:21:08 +00:00
Initial test passed
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/* globals describe, it, before */
|
||||
|
||||
var messageLog = [];
|
||||
var pr = function( msg ){
|
||||
messageLog.push( msg );
|
||||
// console.log( '--', msg );
|
||||
}
|
||||
|
||||
function asyncFn( args ){
|
||||
return function( cb ){
|
||||
setTimeout( function(){
|
||||
pr( args.msg );
|
||||
if( args.error ){
|
||||
if( args.isThrow ){
|
||||
throw args.error;
|
||||
} else {
|
||||
return cb( args.error );
|
||||
}
|
||||
} else {
|
||||
return cb( );
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var beforeFn = asyncFn({
|
||||
msg: 'Before_block',
|
||||
delay: 100,
|
||||
error: null,
|
||||
});
|
||||
|
||||
var it1 = asyncFn({
|
||||
msg: 'It_1',
|
||||
delay: 10,
|
||||
error: null,
|
||||
});
|
||||
|
||||
var it2 = asyncFn({
|
||||
msg: 'It_2',
|
||||
delay: 500,
|
||||
error: null,
|
||||
});
|
||||
|
||||
|
||||
describe( 'describe', function(){
|
||||
|
||||
before( beforeFn );
|
||||
it( 'it1', it1 );
|
||||
it( 'it2', it2 );
|
||||
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
/* globals describe, it, */
|
||||
|
||||
var SimpleMocha = require( __dirname + '/../index-v1' );
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
|
||||
describe( 'Simple before block + it s ', function(){
|
||||
|
||||
it( 'should parse simple test file' , function( done ){
|
||||
|
||||
var runner = SimpleMocha.load( __dirname + '/data/dummy.spec.js' );
|
||||
|
||||
assert( runner );
|
||||
|
||||
var describeBlock = runner.rootDescribeBlock;
|
||||
|
||||
assert( describeBlock );
|
||||
assert( describeBlock instanceof SimpleMocha.DescribeBlock );
|
||||
assert.equal( describeBlock.children.length, 1 );
|
||||
|
||||
var firsDescribeBlock = describeBlock.children[0];
|
||||
|
||||
|
||||
assert( firsDescribeBlock instanceof SimpleMocha.DescribeBlock );
|
||||
assert( firsDescribeBlock.beforeFn );
|
||||
|
||||
done();
|
||||
});
|
||||
})
|
||||
Reference in New Issue
Block a user