Skip to content

Commit 24ef9e4

Browse files
committed
added all tests for new features
1 parent 41d5eee commit 24ef9e4

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

config/Coldbox.cfc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,5 @@ component{
8787
}
8888
};
8989
}
90-
</cfscript>
91-
</cfcomponent>
90+
91+
}

tests/specs/GenericObjectTest.cfc

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,37 @@ www.coldbox.org | www.luismajano.com | www.ortussolutions.com
66
*/
77
component extends="coldbox.system.testing.BaseModelTest" model="cbvalidation.models.GenericObject"{
88

9-
function setup(){
9+
/*********************************** LIFE CYCLE Methods ***********************************/
10+
11+
// executes before all suites+specs in the run() method
12+
function beforeAll(){
13+
super.beforeAll();
1014
super.setup();
11-
model.init( {name="luis", age="33"} );
15+
model.init( { name="luis", age="33" } );
1216
}
1317

14-
function testGet(){
15-
assertEquals("luis", model.getName() );
16-
assertEquals("33", model.getAge() );
18+
// executes after all suites+specs in the run() method
19+
function afterAll(){
20+
super.afterAll();
1721
}
1822

19-
function testBad(){
20-
expect( function(){ model.getThere(); } ).toThrow();
23+
/*********************************** BDD SUITES ***********************************/
24+
25+
function run( testResults, testBox ){
26+
27+
// all your suites go here.
28+
describe( "Generic Object", function(){
29+
30+
it( "can do getters", function(){
31+
expect( model.getName() ).toBe( "luis" );
32+
expect( model.getAge() ).toBe( "33" );
33+
});
34+
35+
it( title="can do null getters", body=function(){
36+
expect( model.getInvalid() ).toBeNull();
37+
} );
38+
39+
});
2140
}
2241

2342
}

tests/specs/ValidationManagerTest.cfc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ component extends="coldbox.system.testing.BaseModelTest" model="cbvalidation.mod
134134
assertEquals( 1, arrayLen( r.getFieldErrors("name") ) );
135135
}
136136

137+
function testWithIncludeFields(){
138+
mockData = { name="", age="" };
139+
mockConstraints = {
140+
name = {required=true}, age = {required=true, max="35"}
141+
};
142+
143+
r = model.validate(target={ age=30 }, constraints=mockConstraints, includeFields="age");
144+
assertEquals( false, r.hasErrors() );
145+
}
146+
137147

138148
private function _validateit( targetValue, target ){
139149
return true;

0 commit comments

Comments
 (0)