Skip to content

Instantly share code, notes, and snippets.

@jsteinshouer
Created September 12, 2017 02:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsteinshouer/25e1c988d9e5851c2191ee219593ca5e to your computer and use it in GitHub Desktop.
Save jsteinshouer/25e1c988d9e5851c2191ee219593ca5e to your computer and use it in GitHub Desktop.
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