Skip to content

Commit

Permalink
Test span logic
Browse files Browse the repository at this point in the history
  • Loading branch information
1602 committed Jul 4, 2010
1 parent 3b929ea commit 6e049c4
Show file tree
Hide file tree
Showing 7 changed files with 1,933 additions and 11 deletions.
58 changes: 58 additions & 0 deletions test/core.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*global Util, test, equals, ok, */
var _ = new Util({});

test('clean_html: span tags', function () {
var textarea = document.createElement('textarea');
document.body.appendChild(textarea);
var wysiwyg = new Wysiwyg(textarea, {
css_path: '/projects/dmitry/wysiwyg/my/common.css'
});
wysiwyg.register_attribute('href');
var tests = [
{
before: "<span style='font-style: italic'>\
<span style='text-decoration: underline'>Text</span>\
</span>",
after: '<i><u>Text</u></i>'
},
{
before: "<span style='font-style: italic'>Text</span>",
after: '<i>Text</i>'
},
{
before: "<span style='font-style: italic'>\
<span style='font-style: italic'>Text</span>\
</span>",
after: '<i>Text</i>'
},
{
before: "<span style='text-decoration: underline'>\
<span style='font-style: italic'>Text1</span>\
<span style='text-decoration: line-through'>Text2</span>\
</span>",
after: '<u>\
<i>Text1</i>\
<s>Text2</s>\
</u>'
},
{
before: "<span style='font-style: oblique'>\
<span style='font-style: italic'><a href='index.html'>Text1</a></span>\
<span style='text-decoration: line-through'>Text2</span>\
</span>",
after: '<i>\
<i><a>Text1</a></i>\
<s>Text2</s>\
</i>'
}
];

for (i in tests) {
var t = tests[i];
wysiwyg.switch_design_mode();
wysiwyg.source.value = t.before;
wysiwyg.switch_design_mode();
wysiwyg.update_textarea();
equals(wysiwyg.source.value, t.after, t.note);
}
});
27 changes: 27 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
<link rel="stylesheet" type="text/css" href="../common.css" />
<link rel="stylesheet" type="text/css" href="../editor.css" />
<script type="text/javascript" src="qunit.js"></script>
<!--script type="text/javascript" src="../my/jquery.js"></script-->
<!-- Your project file goes here -->
<script type="text/javascript" src="../wysiwyg.util.js"></script>
<script type="text/javascript" src="../wysiwyg.core.js"></script>
<script type="text/javascript" src="../wysiwyg.plugins.js"></script>
<script type="text/javascript" src="../wysiwyg.plugin.image_and_file.js"></script>
<script type="text/javascript" src="../form.js"></script>
<!-- Your tests file goes here -->
<script type="text/javascript" src="core.test.js"></script>
</head>
<body>
<h1 id="qunit-header">QUnit test env</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests">
</ol>
</body>
</html>
118 changes: 118 additions & 0 deletions test/qunit.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
ol#qunit-tests {
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
margin:0;
padding:0;
list-style-position:inside;

font-size: smaller;
}
ol#qunit-tests li{
padding:0.4em 0.5em 0.4em 2.5em;
border-bottom:1px solid #fff;
font-size:small;
list-style-position:inside;
}
ol#qunit-tests li ol{
box-shadow: inset 0px 2px 13px #999;
-moz-box-shadow: inset 0px 2px 13px #999;
-webkit-box-shadow: inset 0px 2px 13px #999;
margin-top:0.5em;
margin-left:0;
padding:0.5em;
background-color:#fff;
border-radius:15px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
}
ol#qunit-tests li li{
border-bottom:none;
margin:0.5em;
background-color:#fff;
list-style-position: inside;
padding:0.4em 0.5em 0.4em 0.5em;
}

ol#qunit-tests li li.pass{
border-left:26px solid #C6E746;
background-color:#fff;
color:#5E740B;
}
ol#qunit-tests li li.fail{
border-left:26px solid #EE5757;
background-color:#fff;
color:#710909;
}
ol#qunit-tests li.pass{
background-color:#D2E0E6;
color:#528CE0;
}
ol#qunit-tests li.fail{
background-color:#EE5757;
color:#000;
}
ol#qunit-tests li strong {
cursor:pointer;
}
h1#qunit-header{
background-color:#0d3349;
margin:0;
padding:0.5em 0 0.5em 1em;
color:#fff;
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
border-top-right-radius:15px;
border-top-left-radius:15px;
-moz-border-radius-topright:15px;
-moz-border-radius-topleft:15px;
-webkit-border-top-right-radius:15px;
-webkit-border-top-left-radius:15px;
text-shadow: rgba(0, 0, 0, 0.5) 4px 4px 1px;
}
h2#qunit-banner{
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
height:5px;
margin:0;
padding:0;
}
h2#qunit-banner.qunit-pass{
background-color:#C6E746;
}
h2#qunit-banner.qunit-fail, #qunit-testrunner-toolbar {
background-color:#EE5757;
}
#qunit-testrunner-toolbar {
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
padding:0;
/*width:80%;*/
padding:0em 0 0.5em 2em;
font-size: small;
}
h2#qunit-userAgent {
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
background-color:#2b81af;
margin:0;
padding:0;
color:#fff;
font-size: small;
padding:0.5em 0 0.5em 2.5em;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
p#qunit-testresult{
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
margin:0;
font-size: small;
color:#2b81af;
border-bottom-right-radius:15px;
border-bottom-left-radius:15px;
-moz-border-radius-bottomright:15px;
-moz-border-radius-bottomleft:15px;
-webkit-border-bottom-right-radius:15px;
-webkit-border-bottom-left-radius:15px;
background-color:#D2E0E6;
padding:0.5em 0.5em 0.5em 2.5em;
}
strong b.fail{
color:#710909;
}
strong b.pass{
color:#5E740B;
}
Loading

0 comments on commit 6e049c4

Please sign in to comment.