Archived
1
0

Test_editor() function that actually runs.

This commit is contained in:
Dan Helfman 2007-09-07 21:39:01 +00:00
parent 3955bcb8b9
commit 707c3dbc02

View File

@ -10,10 +10,11 @@
<script language="JavaScript" type="text/javascript" src="../Editor.js"></script> <script language="JavaScript" type="text/javascript" src="../Editor.js"></script>
<script language="JavaScript" type="text/javascript"> <script language="JavaScript" type="text/javascript">
function setUp() { function setUpPage() {
id = "fake_id"; id = "fake_id";
notebook_id = "fake_notebook_id"; notebook_id = "fake_notebook_id";
note_text = "blah"; title = "the title"
note_text = "<h3>" + title + "</h3>blah";
deleted_from = undefined; deleted_from = undefined;
revisions_list = undefined; revisions_list = undefined;
read_write = true; read_write = true;
@ -25,6 +26,18 @@ function setUp() {
init_complete = false; init_complete = false;
connect( editor, "init_complete", function () { init_complete = true; } ); connect( editor, "init_complete", function () { init_complete = true; } );
wait_for_init_complete();
}
function wait_for_init_complete() {
// busywait for the editor initialization to complete
if ( !init_complete ) {
setTimeout( "wait_for_init_complete()", 10 );
return;
}
setUpPageStatus = "complete";
} }
function tearDown() { function tearDown() {
@ -32,25 +45,22 @@ function tearDown() {
} }
function test_Editor() { function test_Editor() {
// busywait for the editor initialization to complete assertNotUndefined( "editor should have changes_button member", editor.changes_button );
if ( !init_complete ) { assertNotUndefined( "editor should have options_button member", editor.options_button );
setTimeout( "test_Editor()", 10 ); assertFalse( "editor should not have closed flag set", editor.closed );
return; assertEquals( "editor should have correct deleted_from flag", editor.deleted_from, deleted_from || null );
} assertNotUndefined( "editor should have document member", editor.document );
assertNotUndefined( "document should have body member", editor.document.body );
assertNotUndefined( editor.changes_button ); assertEquals(
assertNotUndefined( editor.closed ); "document.body.innerHTML should start with note_text",
assertNotUndefined( editor.deleted_from ); editor.document.body.innerHTML.toLowerCase().indexOf( note_text.toLowerCase() ), 0
assertNotUndefined( editor.document ); );
assertNotUndefined( editor.document.body ); assertEquals( "editor id should have correct id", editor.id, id );
assertNotUndefined( editor.document.body.innerHTML ); assertNotUndefined( "editor should have iframe member", editor.iframe );
assertNotUndefined( editor.id ); assertEquals( "editor should have empty revisions list", editor.revisions_list.length, 0 );
assertNotUndefined( editor.iframe ); assertEquals( "editor should have correct startup flag", editor.startup, startup );
assertNotUndefined( editor.revisions_list ); assertEquals( "editor should have correct title", editor.title, title );
assertNotUndefined( editor.startup ); assertEquals( "editor should have correct read_write flag", editor.read_write, read_write );
assertNotUndefined( editor.title );
assertNotUndefined( editor.options_button );
assertNotUndefined( editor.read_write );
} }
</script> </script>