setQuery() 테스트 수정

This commit is contained in:
bnu 2017-06-26 16:20:41 +09:00 committed by Kijin Sung
parent 3754d465e9
commit aee7848706

View file

@ -8,64 +8,77 @@
<script type="text/javascript" src="JSSpec/diff_match_patch.js"></script> <script type="text/javascript" src="JSSpec/diff_match_patch.js"></script>
<script type="text/javascript" src="../jquery.js"></script> <script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../common.js"></script> <script type="text/javascript" src="../common.js"></script>
<script>
var current_url = 'http://xpressengine.com/';
var http_port = 80;
var https_port = 443;
var enforce_ssl = false;
</script>
<script type="text/javascript">// <![CDATA[ <script type="text/javascript">// <![CDATA[
describe('SetQuery', { describe('SetQuery', {
'should satisfy basic uri condition' : function() { 'should satisfy basic uri condition' : function() {
target = "http://xpressengine.com/"; target = "http://xpressengine.com/";
value_of(target.setQuery("q","r")).should_be("http://xpressengine.com/?q=r"); value_of(target.setQuery("q","r")).should_be("http://xpressengine.com/index.php?q=r");
}, },
'should work when ssl is on' : function() { 'should work when ssl is on' : function() {
target = "http://xpressengine.com/"; target = "http://xpressengine.com/";
ssl_actions = new Array("dispLogin"); window.ssl_actions = new Array("dispLogin");
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/?act=dispLogin"); value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/index.php?act=dispLogin");
}, },
'should work when ssl is on and https_port is set (not 443)' : function() { 'should work when ssl is on and https_port is set (not 443)' : function() {
target = "http://xpressengine.com/"; target = "http://xpressengine.com/";
https_port = 445; window.https_port = 445;
ssl_actions = new Array("dispLogin"); window.ssl_actions = new Array("dispLogin");
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com:445/?act=dispLogin"); value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com:445/index.php?act=dispLogin");
}, },
'should work when ssl is on and https_port is set as 443' : function() { 'should work when ssl is on and https_port is set as 443' : function() {
target = "http://xpressengine.com/"; target = "http://xpressengine.com/";
https_port = 443; window.https_port = 443;
ssl_actions = new Array("dispLogin"); window.ssl_actions = new Array("dispLogin");
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/?act=dispLogin"); value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/index.php?act=dispLogin");
}, },
'should replace https to http if act is not a member of ssl_actions': function() { 'should replace https to http if act is not a member of ssl_actions': function() {
targets = "https://xpressengine.com/"; targets = "https://xpressengine.com/";
ssl_actions = new Array("dispLogin"); window.ssl_actions = new Array("dispLogin");
value_of(targets.setQuery("act","dispLogin2")).should_be("http://xpressengine.com/?act=dispLogin2"); value_of(targets.setQuery("act","dispLogin2")).should_be("http://xpressengine.com/index.php?act=dispLogin2");
}, },
'should remove https port' : function() { 'should remove https port' : function() {
targetsp = "https://xpressengine.com:443/?q=r"; targetsp = "https://xpressengine.com:443/index.php?q=r";
value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://xpressengine.com/?q=r&act=dispLogin2"); value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://xpressengine.com/index.php?q=r&act=dispLogin2");
}, },
'should remove https port and add http port if http port is defined' : function() { 'should remove https port and add http port if http port is defined' : function() {
targetsp = "https://xpressengine.com:443/?q=r"; targetsp = "https://xpressengine.com:443/index.php?q=r";
http_port = 8000; window.http_port = 8080;
value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://xpressengine.com:8000/?q=r&act=dispLogin2"); value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://xpressengine.com:8080/index.php?q=r&act=dispLogin2");
}, },
'should only remove https port and if http port is defined as 80' : function() { 'should only remove https port and if http port is defined as 80' : function() {
targetsp = "https://xpressengine.com:443/?q=r"; targetsp = "https://xpressengine.com:443/index.php?q=r";
http_port = 80; window.http_port = 80;
value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://xpressengine.com/?q=r&act=dispLogin2"); value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://xpressengine.com/index.php?q=r&act=dispLogin2");
}, },
'should work if enforce_ssl is set' : function() { 'should work if enforce_ssl is set' : function() {
target = "http://xpressengine.com/"; target = "http://xpressengine.com/";
enforce_ssl = true; window.enforce_ssl = true;
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/?act=dispLogin"); value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/index.php?act=dispLogin");
},
'should work if enforce_ssl is set' : function() {
target = "https://xpressengine.com:4433/";
window.http_port = 8080;
window.https_port = 4433;
window.enforce_ssl = false;
value_of(target.setQuery("act","dispTest")).should_be("http://xpressengine.com:8080/index.php?act=dispTest");
}, },
'should work if enforce_ssl is set with 443 port' : function() { 'should work if enforce_ssl is set with 443 port' : function() {
target = "http://xpressengine.com/"; target = "http://xpressengine.com/";
enforce_ssl = true; window.enforce_ssl = true;
https_port = 443; window.https_port = 443;
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/?act=dispLogin"); value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/index.php?act=dispLogin");
}, },
'should work if enforce_ssl is set with none-443 port' : function() { 'should work if enforce_ssl is set with none-443 port' : function() {
target = "http://xpressengine.com/"; target = "http://xpressengine.com/";
enforce_ssl = true; window.enforce_ssl = true;
https_port = 445; window.https_port = 445;
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com:445/?act=dispLogin"); value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com:445/index.php?act=dispLogin");
} }
}) })
// ]]></script> // ]]></script>