File tree Expand file tree Collapse file tree 3 files changed +38
-9
lines changed Expand file tree Collapse file tree 3 files changed +38
-9
lines changed Original file line number Diff line number Diff line change @@ -87,5 +87,5 @@ component{
87
87
}
88
88
};
89
89
}
90
- < / cfscript >
91
- < / cfcomponent >
90
+
91
+ }
Original file line number Diff line number Diff line change @@ -6,18 +6,37 @@ www.coldbox.org | www.luismajano.com | www.ortussolutions.com
6
6
*/
7
7
component extends = " coldbox.system.testing.BaseModelTest" model = " cbvalidation.models.GenericObject" {
8
8
9
- function setup (){
9
+ /* ********************************** LIFE CYCLE Methods ***********************************/
10
+
11
+ // executes before all suites+specs in the run() method
12
+ function beforeAll (){
13
+ super .beforeAll ();
10
14
super .setup ();
11
- model .init ( {name = " luis" , age = " 33" } );
15
+ model .init ( { name = " luis" , age = " 33" } );
12
16
}
13
17
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 ( );
17
21
}
18
22
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
+ });
21
40
}
22
41
23
42
}
Original file line number Diff line number Diff line change @@ -134,6 +134,16 @@ component extends="coldbox.system.testing.BaseModelTest" model="cbvalidation.mod
134
134
assertEquals ( 1 , arrayLen ( r .getFieldErrors (" name" ) ) );
135
135
}
136
136
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
+
137
147
138
148
private function _validateit ( targetValue , target ){
139
149
return true ;
You can’t perform that action at this time.
0 commit comments