fix tests for ie7
This commit is contained in:
parent
294c5c0528
commit
53ee7f3ff8
25
test/main.js
25
test/main.js
@ -53,4 +53,27 @@ require(["loader", jqurl], function(loader) {
|
||||
config.shim[tests[i+1]] = [tests[i]];
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// implement JSON.stringify serialization for IE7
|
||||
var JSON = JSON || {};
|
||||
JSON.stringify = JSON.stringify || function (obj) {
|
||||
var t = typeof (obj);
|
||||
if (t != "object" || obj === null) {
|
||||
// simple data type
|
||||
if (t == "string") obj = '"'+obj+'"';
|
||||
return String(obj);
|
||||
}
|
||||
else {
|
||||
// recurse array or object
|
||||
var n, v, json = [], arr = (obj && obj.constructor == Array);
|
||||
for (n in obj) {
|
||||
v = obj[n]; t = typeof(v);
|
||||
if (t == "string") v = '"'+v+'"';
|
||||
else if (t == "object" && v !== null) v = JSON.stringify(v);
|
||||
json.push((arr ? "" : '"' + n + '":') + String(v));
|
||||
}
|
||||
return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
|
||||
}
|
||||
};
|
@ -94,7 +94,7 @@ $(function () {
|
||||
});
|
||||
|
||||
e.editable({
|
||||
source: 'groups.php',
|
||||
source: 'groups.php'
|
||||
});
|
||||
|
||||
e.click();
|
||||
@ -103,7 +103,7 @@ $(function () {
|
||||
var p = tip(e);
|
||||
|
||||
test_reason = 'cancel'
|
||||
p.find('button[type=button]').click(); //cancel
|
||||
p.find('.editable-cancel').click(); //cancel
|
||||
ok(!p.is(':visible'), 'popover closed');
|
||||
|
||||
test_reason = 'onblur'
|
||||
@ -147,7 +147,7 @@ $(function () {
|
||||
});
|
||||
|
||||
e.editable({
|
||||
source: groups,
|
||||
source: groups
|
||||
});
|
||||
|
||||
e.click();
|
||||
|
@ -17,7 +17,7 @@ $(function () {
|
||||
value: [2, 3]
|
||||
});
|
||||
|
||||
equal(e.html(), groups[2]+sep+groups[3], 'autotext ok');
|
||||
equal(e.html().toLowerCase(), (groups[2]+sep+groups[3]).toLowerCase(), 'autotext ok');
|
||||
|
||||
$.mockjax({
|
||||
url: 'post-checklist.php',
|
||||
@ -47,7 +47,7 @@ $(function () {
|
||||
ok(!p.is(':visible'), 'popup closed');
|
||||
|
||||
equal(e.data('editable').value.join(''), [newValue, 3].join(''), 'new value ok')
|
||||
equal(e.html(), groups[newValue]+'<br>'+groups[3], 'new text ok');
|
||||
equal(e.html().toLowerCase(), (groups[newValue]+'<br>'+groups[3]).toLowerCase(), 'new text ok');
|
||||
|
||||
// open container again to see what checked
|
||||
e.click()
|
||||
|
@ -274,7 +274,7 @@
|
||||
});
|
||||
|
||||
|
||||
test("should not wrap buttons when parent has position:absolute", function () {
|
||||
test("should not wrap buttons when parent has position:absolute (except ie7)", function () {
|
||||
var d = $('<div style="position: absolute; top: 200px">').appendTo(fx),
|
||||
e = $('<a href="#" data-pk="1" data-url="post.php" data-name="text1">abc</a>').appendTo(d).editable({
|
||||
showbuttons: true
|
||||
|
@ -130,7 +130,7 @@ $(function () {
|
||||
|
||||
equal(p.find('td.day.active').text(), today.getDate(), 'day shown correct');
|
||||
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover closed');
|
||||
});
|
||||
|
||||
|
@ -84,7 +84,7 @@ $(function () {
|
||||
|
||||
equal(p.find('a.ui-state-active').text(), today.getDate(), 'day shown correct');
|
||||
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover closed');
|
||||
});
|
||||
|
||||
|
@ -14,7 +14,7 @@ $(function () {
|
||||
e.click();
|
||||
var p = tip(e);
|
||||
ok(p.find('select').length, 'select exists')
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
})
|
||||
|
||||
@ -36,7 +36,7 @@ $(function () {
|
||||
ok(p.find('select').length, 'select exists');
|
||||
equal(p.find('select').find('option').length, size, 'options loaded');
|
||||
equal(p.find('select').val(), e.data('editable').value, 'selected value correct') ;
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
e.remove();
|
||||
start();
|
||||
@ -57,7 +57,7 @@ $(function () {
|
||||
ok(p.find('select').length, 'select exists')
|
||||
equal(p.find('select').find('option').length, size, 'options loaded')
|
||||
equal(p.find('select').val(), e.data('editable').value, 'selected value correct')
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
});
|
||||
|
||||
@ -75,7 +75,7 @@ $(function () {
|
||||
equal(p.find('select').find('option').length, groupsArr.length, 'options loaded');
|
||||
equal(p.find('select').val(), e.data('editable').value, 'selected value correct');
|
||||
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
});
|
||||
|
||||
@ -93,7 +93,7 @@ $(function () {
|
||||
ok(p.find('select').length, 'select exists')
|
||||
equal(p.find('select').find('option').length, arr.length, 'options loaded')
|
||||
equal(p.find('select').val(), 'x', 'selected value correct')
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
});
|
||||
|
||||
@ -112,7 +112,7 @@ $(function () {
|
||||
ok(p.find('select').length, 'select exists');
|
||||
equal(p.find('select').find('option').length, size+1, 'options loaded');
|
||||
equal(p.find('select').val(), e.data('editable').value, 'selected value correct') ;
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
});
|
||||
|
||||
@ -128,7 +128,7 @@ $(function () {
|
||||
ok(p.find('select').length, 'select exists');
|
||||
equal(p.find('select').find('option').length, size, 'options loaded');
|
||||
equal(p.find('select').val(), e.data('editable').value, 'selected value correct') ;
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
})
|
||||
|
||||
@ -144,7 +144,7 @@ $(function () {
|
||||
ok(p.find('select').length, 'select exists');
|
||||
equal(p.find('select').find('option').length, size, 'options loaded');
|
||||
equal(p.find('select').val(), e.data('editable').value, 'selected value correct') ;
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
})
|
||||
|
||||
@ -162,7 +162,7 @@ $(function () {
|
||||
equal(p.find('select').find('option').length, 0, 'options not loaded');
|
||||
equal(p.find('.editable-error-block').text(), 'error', 'sourceError message shown');
|
||||
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
})
|
||||
|
||||
@ -179,7 +179,7 @@ $(function () {
|
||||
ok(!p.find('select').find('option').length, 'options not loaded')
|
||||
ok(p.find('button[type=submit]:disabled').length, 'submit-btn disabled')
|
||||
ok(p.find('.editable-error-block').text().length, 'error shown')
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
e.remove();
|
||||
start();
|
||||
@ -290,7 +290,7 @@ $(function () {
|
||||
equal(p.find('select').find('option').length, size, 'options loaded');
|
||||
equal(req, 1, 'one request performed');
|
||||
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
|
||||
//click second
|
||||
@ -302,7 +302,7 @@ $(function () {
|
||||
equal(p.find('select').find('option').length, size, 'options loaded');
|
||||
equal(req, 1, 'no extra request, options taken from cache');
|
||||
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
|
||||
e.remove();
|
||||
@ -409,7 +409,7 @@ $(function () {
|
||||
equal(p.find('select').find('option').length, size, 'options loaded');
|
||||
equal(req, 1, 'one request performed');
|
||||
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
|
||||
//click second
|
||||
@ -421,7 +421,7 @@ $(function () {
|
||||
equal(p.find('select').find('option').length, size, 'options loaded');
|
||||
equal(req, 2, 'second request performed');
|
||||
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
|
||||
e.remove();
|
||||
@ -496,7 +496,7 @@ $(function () {
|
||||
ok(p.is(':visible'), 'popover visible');
|
||||
equal(p.find('select').find('option').length, 3, 'options prepended (sync)');
|
||||
equal(p.find('select').val(), '', 'selected value correct');
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
|
||||
//async
|
||||
@ -513,7 +513,7 @@ $(function () {
|
||||
ok(p.is(':visible'), 'popover visible');
|
||||
equal(p.find('select').find('option').length, size+1, 'options prepended (async)');
|
||||
equal(p.find('select').val(), 'r', 'selected value correct');
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
e.remove();
|
||||
start();
|
||||
|
@ -15,8 +15,8 @@ $(function () {
|
||||
|
||||
e.click();
|
||||
var p = tip(e);
|
||||
equal(p.find('input[type=text]').val(), '', 'input val is empty string')
|
||||
p.find('button[type=button]').click();
|
||||
equal(p.find('input[type="text"]').val(), '', 'input val is empty string')
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed')
|
||||
})
|
||||
|
||||
@ -26,7 +26,7 @@ $(function () {
|
||||
e.click();
|
||||
var p = tip(e);
|
||||
equal(p.find('input[type=text]').attr('placeholder'), 'abc', 'placeholder exists');
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
});
|
||||
|
||||
@ -36,7 +36,7 @@ $(function () {
|
||||
e.click();
|
||||
var p = tip(e);
|
||||
ok(p.find('input[type=text]').hasClass('span4'), 'class set correctly');
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
});
|
||||
|
||||
@ -104,9 +104,9 @@ $(function () {
|
||||
setTimeout(function() {
|
||||
ok(p.is(':visible'), 'popover still shown');
|
||||
ok(p.find('.editable-error-block').length, 'class "editable-error-block" exists');
|
||||
equal(p.find('.editable-error-block').text(), msg.replace('\n', ''), 'error msg shown');
|
||||
equal(p.find('.editable-error-block').html(), msg.replace('\n', '<br>'), 'newline replaced with br');
|
||||
p.find('button[type=button]').click();
|
||||
equal(p.find('.editable-error-block').text().toLowerCase(), msg.replace('\n', ''), 'error msg shown');
|
||||
equal(p.find('.editable-error-block').html().toLowerCase(), msg.replace('\n', '<br>'), 'newline replaced with br');
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
e.remove();
|
||||
start();
|
||||
@ -137,7 +137,7 @@ $(function () {
|
||||
ok(p.is(':visible'), 'popover still shown');
|
||||
ok(p.find('.error').length, 'class "error" exists');
|
||||
equal(p.find('.editable-error-block').text(), 'required1', 'error msg shown');
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
|
||||
e = e1;
|
||||
@ -148,7 +148,7 @@ $(function () {
|
||||
ok(p.is(':visible'), 'popover still shown');
|
||||
ok(p.find('.error').length, 'class "error" exists');
|
||||
equal(p.find('.editable-error-block').text(), 'required2', 'error msg shown');
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
});
|
||||
*/
|
||||
@ -174,7 +174,7 @@ $(function () {
|
||||
ok(p.is(':visible'), 'popover still shown');
|
||||
ok(p.find('.editable-error-block').length, 'class "editable-error-block" exists');
|
||||
equal(p.find('.editable-error-block').text(), 'error', 'error msg shown');
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
e.remove();
|
||||
start();
|
||||
@ -204,7 +204,7 @@ $(function () {
|
||||
equal(e.data('editable').value, 'xyz', 'value ok');
|
||||
equal(e.text(), 'xyz', 'text ok');
|
||||
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
e.remove();
|
||||
start();
|
||||
@ -309,7 +309,7 @@ $(function () {
|
||||
ok(p.find('.editable-error-block').length, 'class "error" exists')
|
||||
equal(p.find('.editable-error-block').text(), 'customtext', 'error shown')
|
||||
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed')
|
||||
|
||||
e.remove();
|
||||
@ -339,7 +339,7 @@ $(function () {
|
||||
ok(p.find('.error').length, 'class "error" exists')
|
||||
equal(p.find('.editable-error-block').text(), 'Internal server error', 'error shown')
|
||||
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed')
|
||||
|
||||
e.remove();
|
||||
|
@ -16,7 +16,7 @@ $(function () {
|
||||
var p = tip(e);
|
||||
ok(p.find('textarea').length, 'textarea exists')
|
||||
ok(!p.find('textarea').val().length, 'textrea is empty')
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed')
|
||||
})
|
||||
|
||||
@ -25,7 +25,7 @@ $(function () {
|
||||
e.click()
|
||||
var p = tip(e);
|
||||
equal(p.find('textarea').attr('placeholder'), 'abc', 'placeholder exists');
|
||||
p.find('button[type=button]').click();
|
||||
p.find('.editable-cancel').click();
|
||||
ok(!p.is(':visible'), 'popover was removed');
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user