[#25] Refactored quickVisChangeTest to share code between each of the member test cases
parent
3c676de55d
commit
08cb663833
|
@ -44,17 +44,12 @@ require( 'common' ).testCase(
|
|||
|
||||
this.quickVisChangeTest = function( start, override, failtest )
|
||||
{
|
||||
var name = 'foo',
|
||||
|
||||
startobj = { 'virtual': true },
|
||||
overrideobj = { 'override': true }
|
||||
;
|
||||
|
||||
startobj[ start ] = true;
|
||||
overrideobj[ override ] = true;
|
||||
|
||||
var testfun = function()
|
||||
shared.quickVisChangeTest.call( _self, start, override, failtest,
|
||||
function( name, startobj, overrideobj )
|
||||
{
|
||||
startobj.virtual = true;
|
||||
overrideobj.override = true;
|
||||
|
||||
_self.sut.validateMethod(
|
||||
name,
|
||||
function() {},
|
||||
|
@ -62,16 +57,8 @@ require( 'common' ).testCase(
|
|||
{ member: function() {} },
|
||||
startobj
|
||||
);
|
||||
};
|
||||
|
||||
if ( failtest )
|
||||
{
|
||||
this.quickFailureTest( name, 'de-escalate', testfun );
|
||||
}
|
||||
else
|
||||
{
|
||||
_self.assertDoesNotThrow( testfun, Error );
|
||||
}
|
||||
);
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ require( 'common' ).testCase(
|
|||
{
|
||||
caseSetUp: function()
|
||||
{
|
||||
var _self = this;
|
||||
|
||||
this.quickFailureTest = shared.quickFailureTest;
|
||||
|
||||
this.quickKeywordPropTest = function( keywords, identifier, prev )
|
||||
|
@ -40,33 +42,16 @@ require( 'common' ).testCase(
|
|||
|
||||
this.quickVisChangeTest = function( start, override, failtest )
|
||||
{
|
||||
var _self = this,
|
||||
name = 'foo',
|
||||
|
||||
startobj = {},
|
||||
overrideobj = {}
|
||||
;
|
||||
|
||||
startobj[ start ] = true;
|
||||
overrideobj[ override ] = true;
|
||||
|
||||
var testfun = function()
|
||||
shared.quickVisChangeTest.call( _self, start, override, failtest,
|
||||
function( name, startobj, overrideobj )
|
||||
{
|
||||
_self.sut.validateProperty(
|
||||
name, 'bar', overrideobj,
|
||||
{ member: 'foo' },
|
||||
startobj
|
||||
);
|
||||
};
|
||||
|
||||
if ( failtest )
|
||||
{
|
||||
this.quickFailureTest( name, 'de-escalate', testfun );
|
||||
}
|
||||
else
|
||||
{
|
||||
_self.assertDoesNotThrow( testfun, Error );
|
||||
}
|
||||
);
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
@ -147,3 +147,44 @@ exports.visEscalationTest = function( test )
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Performs a simple visibility change test using access modifiers
|
||||
*
|
||||
* Important: invoke within the context of the test case.
|
||||
*
|
||||
* @param {string} start start keyword
|
||||
* @param {string} override overriding keyword
|
||||
* @param {bool} failtest whether the assertion should test for failure
|
||||
*
|
||||
* @param {function()} func test function
|
||||
*
|
||||
* @return {undefined}
|
||||
*/
|
||||
exports.quickVisChangeTest = function( start, override, failtest, func )
|
||||
{
|
||||
var _self = this,
|
||||
name = 'foo',
|
||||
|
||||
startobj = {},
|
||||
overrideobj = {}
|
||||
;
|
||||
|
||||
startobj[ start ] = true;
|
||||
overrideobj[ override ] = true;
|
||||
|
||||
var testfun = function()
|
||||
{
|
||||
func( name, startobj, overrideobj );
|
||||
};
|
||||
|
||||
if ( failtest )
|
||||
{
|
||||
this.quickFailureTest( name, 'de-escalate', testfun );
|
||||
}
|
||||
else
|
||||
{
|
||||
_self.assertDoesNotThrow( testfun, Error );
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue