Instantly share code, notes, and snippets.

Embed
What would you like to do?
Approval test after converting to Coldbox
/**
* My BDD Test
*/
component extends="coldbox.system.testing.BaseTestCase" appMapping="/root" {
/*********************************** LIFE CYCLE Methods ***********************************/
// executes before all suites+specs in the run() method
function beforeAll(){
super.beforeAll();
addMatchers( "testbox-snapshots.SnapshotMatchers" );
}
// executes after all suites+specs in the run() method
function afterAll(){
super.afterAll();
}
/*********************************** BDD SUITES ***********************************/
function run(){
describe( "RefactorApprovalTest", function(){
beforeEach(function( currentSpec ){
setup();
content = "";
/* Add some data for our tests */
queryExecute("
delete from todo;
--reset the identity so the keys match
ALTER TABLE todo ALTER COLUMN p_todo_id RESTART WITH 1;
insert into todo(p_todo_id,description,completed_date)
values
(1,'Do This',NULL),
(2,'And this',NULL),
(3,'This is done','2017-09-01 01:45:00')
");
});
it( "should display a list of to-do items", function(){
var event = execute( event="index", renderResults=true );
content = event.getValue( name="cbox_rendered_content" );
expect(content).toMatchSnapshot();
});
it( "should display a list of completed to-do items", function(){
url.action = "completed";
var event = execute( event="index", renderResults=true );
content = event.getValue( name="cbox_rendered_content" );
expect(content).toMatchSnapshot();
});
it( "should add a new to-do item", function(){
url.action = "add";
form.description = "another thing to do";
var event = execute( event="index", renderResults=true );
content = event.getValue( name="cbox_rendered_content" );
expect(content).toMatchSnapshot();
});
it( "should complete a to-do item", function(){
url.action = "complete-todo";
form.id = 1;
var event = execute( event="index", renderResults=true );
content = event.getValue( name="cbox_rendered_content" );
expect(content).toMatchSnapshot();
});
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment