Merge "JSCS Cleanup - Legacy JS test files"

This commit is contained in:
Jenkins 2015-06-05 15:15:09 +00:00 committed by Gerrit Code Review
commit e819dac5c9
4 changed files with 54 additions and 38 deletions

View File

@ -1,8 +1,8 @@
module("Instances (horizon.instances.js)");
test("decrypt password ", function () {
var enc_password, private_key, password;
enc_password = "dusPDCoY0u7PqDgVE6M+XicV+8V1qQkuPipM+KoCJ5cS" +
var encPassword, privateKey, password;
encPassword = "dusPDCoY0u7PqDgVE6M+XicV+8V1qQkuPipM+KoCJ5cS" +
"i8Bo64WOspsgjBQwC9onGX5pHwbgZdtintG1QNiDTafNbtNNbRoZQwO" +
"4Zm3Liiw9ymDdiy1GNwMduFiRP9WG5N4QE3TP3ChnWnVGYQE/QoHqa/" +
"7e43LXYvLULQA7tQ7JxhJruRZVt/tskPJGEbgpyjiA3gECjFi12BAKD" +
@ -10,7 +10,7 @@ test("decrypt password ", function () {
"LXZhGaZgMRVKnKREkkTxfmLWtdY5lsWP4dnvHama+k9Ku8LQ+n4qB07" +
"jFVAUmRkpbdDPJ9Nxtlep0g==";
private_key = "-----BEGIN RSA PRIVATE KEY-----" +
privateKey = "-----BEGIN RSA PRIVATE KEY-----" +
"MIIEpAIBAAKCAQEAtY2Be8SoiE5XD/p7WaO2dKUES5iI4l4YAJ1FfpLGsT5mkC1t" +
"7Zl0QTMVMdUNYH7ERIKNv8OSZ/wmm716iStiYPzwjyXUA8uVQuoprUr8hPOeNeHK" +
"f1Nt7F87EPHk/n0VkLsUGZnwxVV1X3hgKS/f2gyPjkKwC+LOTMx81k65kp0a0Qt4" +
@ -38,13 +38,13 @@ test("decrypt password ", function () {
"3ns5u8JfZ0JobJ5JxiKHS3UOqfe9DV2pvVSyF3nLl8I0WPMgoEXrLw==" +
"-----END RSA PRIVATE KEY-----";
password = horizon.instances.decrypt_password(enc_password, private_key);
password = horizon.instances.decrypt_password(encPassword, privateKey);
ok(password === "kLhfIDlK5e7v12");
});
test("decrypt password fake key", function () {
var enc_password, private_key, password;
enc_password = "dusPDCoY0u7PqDgVE6M+XicV+8V1qQkuPipM+KoCJ5cS" +
var encPassword, privateKey, password;
encPassword = "dusPDCoY0u7PqDgVE6M+XicV+8V1qQkuPipM+KoCJ5cS" +
"i8Bo64WOspsgjBQwC9onGX5pHwbgZdtintG1QNiDTafNbtNNbRoZQwO" +
"4Zm3Liiw9ymDdiy1GNwMduFiRP9WG5N4QE3TP3ChnWnVGYQE/QoHqa/" +
"7e43LXYvLULQA7tQ7JxhJruRZVt/tskPJGEbgpyjiA3gECjFi12BAKD" +
@ -52,7 +52,7 @@ test("decrypt password fake key", function () {
"LXZhGaZgMRVKnKREkkTxfmLWtdY5lsWP4dnvHama+k9Ku8LQ+n4qB07" +
"jFVAUmRkpbdDPJ9Nxtlep0g==";
private_key = "-----BEGIN RSA PRIVATE KEY-----" +
privateKey = "-----BEGIN RSA PRIVATE KEY-----" +
"MIIEpAIBAAKCAQEAtY2Be8SoiE5XD/p7WaO2dKUES5iI4l4YAJ1FfpLGsT5mkC1t" +
"Lq3//CLBSnm7gWdOsdU4rBn1khGKrlNdpvIjwkbMYtGlhjbvtwX3JbLlC8If9U00" +
"NbobtwKBgQCxp5+NmeU+NHXeG4wFLyT+hkZncapmV8QvlYmqMuEC6G2rjmplobgX" +
@ -60,6 +60,6 @@ test("decrypt password fake key", function () {
"3ns5u8JfZ0JobJ5JxiKHS3UOqfe9DV2pvVSyF3nLl8I0WPMgoEXrLw==" +
"-----END RSA PRIVATE KEY-----";
password = horizon.instances.decrypt_password(enc_password, private_key);
password = horizon.instances.decrypt_password(encPassword, privateKey);
ok(password === false || password === null);
});
});

View File

@ -5,34 +5,46 @@ horizon.addInitFunction(function () {
test("Basic Alert", function () {
message = horizon.alert("success", "A message!");
ok(message, "Create a success message.");
ok(message.hasClass("alert-success"), 'Verify the message has the "alert-success" class.');
equal($('#main_content .messages .alert').length, 1, "Verify our message was added to the DOM.");
ok(message.hasClass("alert-success"),
'Verify the message has the "alert-success" class.');
equal($('#main_content .messages .alert').length, 1,
"Verify our message was added to the DOM.");
horizon.clearAllMessages();
equal($('#main_content .messages .alert').length, 0, "Verify our message was removed.");
equal($('#main_content .messages .alert').length, 0,
"Verify our message was removed.");
});
test("Multiple Alerts", function () {
message = horizon.alert("error", "An error!");
ok(message.hasClass("alert-danger"), 'Verify the first message has the "alert-danger" class.');
ok(message.hasClass("alert-danger"),
'Verify the first message has the "alert-danger" class.');
message2 = horizon.alert("success", "Another message");
equal($('#main_content .messages .alert').length, 2, "Verify two messages have been added to the DOM.");
equal($('#main_content .messages .alert').length, 2,
"Verify two messages have been added to the DOM.");
horizon.clearErrorMessages();
equal($('#main_content .messages .alert-danger').length, 0, "Verify our error message was removed.");
equal($('#main_content .messages .alert').length, 1, "Verify one message remains.");
equal($('#main_content .messages .alert-danger').length, 0,
"Verify our error message was removed.");
equal($('#main_content .messages .alert').length, 1,
"Verify one message remains.");
horizon.clearSuccessMessages();
equal($('#main_content .messages .alert-success').length, 0, "Verify our success message was removed.");
equal($('#main_content .messages .alert').length, 0, "Verify no messages remain.");
equal($('#main_content .messages .alert-success').length, 0,
"Verify our success message was removed.");
equal($('#main_content .messages .alert').length, 0,
"Verify no messages remain.");
});
test("Alert With HTML Tag", function () {
var safe_string = "A safe message <a>here</a>!";
message = horizon.alert("success", safe_string, "safe");
var safeString = "A safe message <a>here</a>!";
message = horizon.alert("success", safeString, "safe");
ok(message, "Create a message with extra tag.");
ok((message.html().indexOf(safe_string) !== -1), 'Verify the message with HTML tag was not escaped.');
equal($('#main_content .messages .alert').length, 1, "Verify our message was added to the DOM.");
ok((message.html().indexOf(safeString) !== -1),
"Verify the message with HTML tag was not escaped.");
equal($('#main_content .messages .alert').length, 1,
"Verify our message was added to the DOM.");
horizon.clearAllMessages();
equal($('#main_content .messages .alert').length, 0, "Verify our message was removed.");
equal($('#main_content .messages .alert').length, 0,
"Verify our message was removed.");
});
});

View File

@ -2,10 +2,10 @@ horizon.addInitFunction(function () {
module("Modals (horizon.modals.js)");
test("Modal Creation", function () {
var modal,
title = "Test Title",
body = "<p>Test Body</p>",
confirm = "Test Confirm";
var modal;
var title = "Test Title";
var body = "<p>Test Body</p>";
var confirm = "Test Confirm";
modal = horizon.modals.create(title, body, confirm);
ok(modal, "Verify our modal was created.");
@ -13,9 +13,12 @@ horizon.addInitFunction(function () {
modal.modal();
equal(modal.length, 1, "Verify our modal was added to the DOM.");
ok(modal.hasClass("in"), "Verify our modal is not hidden.");
equal(modal.find("h3").text(), title, "Verify the title was added correctly.");
equal(modal.find(".modal-body").text().trim(), body, "Verify the body was added correctly.");
equal(modal.find(".modal-footer .btn-primary").text(), confirm, "Verify the footer confirm button was added correctly.");
equal(modal.find("h3").text(), title,
"Verify the title was added correctly.");
equal(modal.find(".modal-body").text().trim(), body,
"Verify the body was added correctly.");
equal(modal.find(".modal-footer .btn-primary").text(), confirm,
"Verify the footer confirm button was added correctly.");
modal.find(".modal-footer .cancel").click();
ok(!modal.hasClass("in"), "Verify our modal is hidden.");
});

View File

@ -24,7 +24,7 @@ test("Footer count update", function () {
var fixture = $("#qunit-fixture");
var table = fixture.find("#table1");
var tbody = table.find('tbody');
var table_count = table.find("span.table_count");
var tableCount = table.find("span.table_count");
var rows = tbody.find('tr');
// The following function returns the first set of consecutive numbers.
@ -33,27 +33,27 @@ test("Footer count update", function () {
// If you want to match '4' for your numeric value, the following are ok:
// "there are 4 lights", "4 lights there are", "lights there are 4" but
// not "there are 14 lights".
var get_consec_nums = function(str) { return (str.match(/\d+/) || [""])[0]; };
var getConsecNums = function(str) { return (str.match(/\d+/) || [""])[0]; };
horizon.datatables.update_footer_count(table);
equal(get_consec_nums(table_count.text()), '4', "Initial count is correct");
equal(getConsecNums(tableCount.text()), '4', "Initial count is correct");
// hide rows
rows.first().hide();
rows.first().next().hide();
horizon.datatables.update_footer_count(table);
equal(get_consec_nums(table_count.text()), '2', "Count correct after hiding two rows");
equal(getConsecNums(tableCount.text()), '2', "Count correct after hiding two rows");
// show a row
rows.first().next().show();
horizon.datatables.update_footer_count(table);
equal(get_consec_nums(table_count.text()), '3', "Count correct after showing one row");
equal(getConsecNums(tableCount.text()), '3', "Count correct after showing one row");
// add rows
$('<tr><td>cat3</td></tr>"').appendTo(tbody);
$('<tr><td>cat4</td></tr>"').appendTo(tbody);
horizon.datatables.update_footer_count(table);
equal(get_consec_nums(table_count.text()), '5', "Count correct after adding two rows");
equal(getConsecNums(tableCount.text()), '5', "Count correct after adding two rows");
});
test("Formset reenumerate rows", function () {
@ -87,11 +87,12 @@ test("Formset delete row", function () {
test("Formset add row", function() {
var html = $('#formset');
var table = html.find('table');
var empty_row_html = '<tr><td><input id="id_flavors-__prefix__-name" name="flavors-__prefix__-name"></td></tr>';
var emptyRowHtml = '<tr><td><input id="id_flavors-__prefix__-name" ' +
'name="flavors-__prefix__-name"></td></tr>';
equal(table.find('tbody tr').length, 3);
equal(html.find('#id_flavors-TOTAL_FORMS').val(), 3);
horizon.formset_table.add_row(table, 'flavors', empty_row_html);
horizon.formset_table.add_row(table, 'flavors', emptyRowHtml);
equal(table.find('tbody tr').length, 4);
equal(table.find('tbody tr:last input').attr('id'), 'id_flavors-3-name');
equal(html.find('#id_flavors-TOTAL_FORMS').val(), 4);