Hey all,
so i have added testbox into our cf11 testbox that has a CB 2.6.3 setup on it. I am trying to test a basic search cycle. we have a handler that sets some stuff up, then calls the model function which brings data back to a jqgrid. I am not sure if my testbox function should call the handler or just the model…i hope i can test this through the handler…if so my handler could possibly be weird so i need some help. so here is the code:
component extends=“testbox.system.testing.BaseSpec”{
function run(){
describe(“A suite”, function(){
beforeEach(function() {
handler = createObject(“component”,“handlers.ehlcjrExternal”);
event = createObject (“coldbox.system.beans.requestContext”);
coldbox = 22;
});
it(“can have more than one expectation and talk to scopes”, function() {
expect( coldbox ).toBe( 22 );
});
it(“should return data for the grid”, function(){
//this setting up the object
businessHandler = handler.dspQuickJobOrderSearchGridData(event);
expect( businessHandler ).isGT( 0, ‘This returned 0 records’);
});
});
}
}
below is the handler function:
var rc = Event.getCollection(); //Init profile Object var objLCJRExternal = instance.lcjrExternal; var objLCJRUtil = instance.lcjrUtil; Var case_number = ""; var create_date = ""; var employer_business_name = ""; var job_title = ""; var status_id = ""; var post_end_date = ""; var startSearch = ""; var state = ""; var state_id = ""; var visa_class_id = ""; var naic_code = ""; var naic_title = ""; rc.qryCases = ""; startSearch = event.getValue("startSearch",''); case_number = event.getValue("case_number",''); employer_business_name = event.getValue("employer_business_name",''); visa_class_id = event.getValue("visa_class_id",''); status_id = event.getValue("status_id",''); state_id = event.getValue("state_id",''); location_range = event.getValue("location_range",''); location_zipcode = event.getValue("location_zipcode",''); job_title = event.getValue("job_title",''); create_date = event.getValue("create_date",''); post_end_date = event.getValue("post_end_date",''); state = event.getValue("state",''); naic_code = event.getValue("naic_code",''); naic_title = event.getValue("naic_title",'');rc.strZipCodePassed = objLCJRUtil.getZipCodesNearby(location_zipcode,location_range);
rc.qryCases = objLCJRExternal.getQuickJobOrderSearchGridData(rc.page,rc.rows,rc.sidx,rc.sord,startSearch,case_number,employer_business_name,visa_class_id,status_id,state_id,job_title,create_date,post_end_date,state,naic_code,naic_title,rc.strZipCodePassed);
event.renderData(type=“JSON”,data=rc.qryCases);
I have had issues with the event passing in, then the instance var was a problem…so from checking my code above, can i test this the way I want to, or do I have to do some crazy stuff to get this to work? We have much crazier handler functions than this, but the event and instance is part of all our functions…
Any thoughts on this as I try to learn testbox?
thanks
Dan