Annotation of kupuMPIWG/tests/test_plone.js, revision 1.1
1.1 ! dwinter 1: /*****************************************************************************
! 2: *
! 3: * Copyright (c) 2003-2005 Kupu Contributors. All rights reserved.
! 4: *
! 5: * This software is distributed under the terms of the Kupu
! 6: * License. See LICENSE.txt for license text. For a list of Kupu
! 7: * Contributors see CREDITS.txt.
! 8: *
! 9: *****************************************************************************/
! 10:
! 11: // $Id: test_plone.js 9982 2005-03-21 09:53:57Z yuppie $
! 12:
! 13: // Various tests for html -> xhtml processing.
! 14:
! 15: function KupuPloneTestCase() {
! 16: SelectionTestCase.apply(this);
! 17: this.base_setUp = this.setUp;
! 18: this.name = 'KupuPloneTestCase';
! 19:
! 20: this.incontext = function(s) {
! 21: return '<html><head><title>test</title></head><body>'+s+'</body></html>';
! 22: }
! 23: this.verifyResult = function(actual, expected) {
! 24: //var expected = this.incontext(exp);
! 25:
! 26: if (actual == expected)
! 27: return;
! 28:
! 29: var context = /<html><head><title>test<\/title><\/head><body>(.*)<\/body><\/html>/;
! 30: if (context.test(actual) && context.test(expected)) {
! 31: var a = context.exec(actual)[1];
! 32: var e = context.exec(expected)[1];
! 33: throw('Assertion failed: ' + a + ' != ' + e);
! 34: }
! 35: throw('Assertion failed: ' + actual + ' != ' + expected);
! 36: }
! 37:
! 38: this.setUp = function() {
! 39: this.base_setUp();
! 40: this.editor = new KupuEditor(this.kupudoc, {}, null);
! 41: this.ui = new PloneKupuUI('kupu-tb-styles');
! 42: this.ui.editor = this.editor;
! 43: };
! 44:
! 45: this.testRelativeLinks1 = function() {
! 46: var data = '<a href="http://localhost/cms/folder/emptypage#_ftnref1">[1]</a>';
! 47: var expected = '<a href="#_ftnref1">[1]</a>';
! 48: var base = 'http://localhost/cms/folder/';
! 49:
! 50: var actual = this.editor.makeLinksRelative(data, base);
! 51: this.verifyResult(actual, expected);
! 52: }
! 53:
! 54: this.testRelativeLinks2 = function() {
! 55: var data = '<a href="http://localhost/cms/folder/otherdoc#key">[1]</a>';
! 56: var expected = '<a href="otherdoc#key">[1]</a>';
! 57: var base = 'http://localhost/cms/folder/';
! 58:
! 59: var actual = this.editor.makeLinksRelative(data, base);
! 60: this.verifyResult(actual, expected);
! 61: }
! 62:
! 63: this.testRelativeLinks3 = function() {
! 64: var data = '<a href="http://localhost/cms/otherfolder/otherdoc">[1]</a>';
! 65: var expected = '<a href="../otherfolder/otherdoc">[1]</a>';
! 66: var base = 'http://localhost/cms/folder/';
! 67:
! 68: var actual = this.editor.makeLinksRelative(data, base);
! 69: this.verifyResult(actual, expected);
! 70: }
! 71:
! 72: this.testRelativeLinks4 = function() {
! 73: var data = '<a href="http://localhost:9080/plone/Members/admin/art1">[1]</a>';
! 74: var expected = '<a href="art1">[1]</a>';
! 75: var base = 'http://localhost:9080/plone/Members/admin/art1';
! 76:
! 77: var actual = this.editor.makeLinksRelative(data, base);
! 78: this.verifyResult(actual, expected);
! 79: }
! 80:
! 81: this.testRelativeLinks5 = function() {
! 82: var data = '<a href="http://localhost:9080/plone/Members/admin/art1/subitem">[1]</a>';
! 83: var expected = '<a href="art1/subitem">[1]</a>';
! 84: var base = 'http://localhost:9080/plone/Members/admin/art1';
! 85:
! 86: var actual = this.editor.makeLinksRelative(data, base);
! 87: this.verifyResult(actual, expected);
! 88: }
! 89:
! 90: this.testRelativeLinks6 = function() {
! 91: var data = '<a href="http://localhost:9080/plone/Members/admin">[1]</a>';
! 92: var expected = '<a href=".">[1]</a>';
! 93: var base = 'http://localhost:9080/plone/Members/admin/art1';
! 94:
! 95: var actual = this.editor.makeLinksRelative(data, base);
! 96: this.verifyResult(actual, expected);
! 97: }
! 98:
! 99: this.testSetTextStyle = function() {
! 100: var data = '<p>line 1</p><div class="Caption">line 2</div><div class="Caption">line 3</div>';
! 101: // select .....................................|e 2</div><div class="Caption">line|...
! 102: var expected = '<p>line 1</p><h2>line 2</h2><h2>line 3</h2>';
! 103: this.body.innerHTML = data;
! 104: this._setSelection(10, null, 18, null, 'e 2line');
! 105: this.ui.setTextStyle('h2');
! 106: this.assertEquals(this._cleanHtml(this.body.innerHTML), expected);
! 107: }
! 108: }
! 109:
! 110: KupuPloneTestCase.prototype = new SelectionTestCase;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>