';
+ expect(table.find('tbody tr').length).toEqual(3);
+ expect(html.find('#id_flavors-TOTAL_FORMS').val()).toEqual("3");
+ horizon.formset_table.add_row(table, 'flavors', empty_row_html);
+ expect(table.find('tbody tr').length).toEqual(4);
+ expect(table.find('tbody tr:last input').attr('id')).toEqual('id_flavors-3-name');
+ expect(html.find('#id_flavors-TOTAL_FORMS').val()).toEqual("4");
+ });
+ });
+
+ describe("Init formset table", function () {
+ var html, table;
+
+ beforeEach(function () {
+ html = $('#formset');
+ table = html.find('table');
+ });
+
+ it("add row", function () {
+ horizon.formset_table.init('flavors', '', 'Add row');
+ expect(table.find('tfoot tr a').html()).toEqual('Add row');
+ });
+
+ it("no add row", function () {
+ $('tfoot tr a').remove();
+ horizon.formset_table.init('flavors', '', '');
+ expect(table.find('tfoot tr a').length).toEqual(0);
+ });
+ });
+});
\ No newline at end of file
diff --git a/horizon/static/horizon/tests/jasmine/templates.legacy-spec.js b/horizon/static/horizon/tests/jasmine/templates.legacy-spec.js
new file mode 100644
index 0000000000..0b15aea72b
--- /dev/null
+++ b/horizon/static/horizon/tests/jasmine/templates.legacy-spec.js
@@ -0,0 +1,9 @@
+describe("Client-Side Templating (horizon.templates.js)", function () {
+ it("Compiled templates list should not be empty.", function () {
+ var size = 0;
+ angular.forEach(horizon.templates.compiled_templates, function () {
+ size = size + 1;
+ });
+ expect(size).toBeGreaterThan(0);
+ });
+});
\ No newline at end of file
diff --git a/horizon/static/horizon/tests/messages.js b/horizon/static/horizon/tests/messages.js
deleted file mode 100644
index cc7d9f377b..0000000000
--- a/horizon/static/horizon/tests/messages.js
+++ /dev/null
@@ -1,50 +0,0 @@
-horizon.addInitFunction(function () {
- module("Messages (horizon.messages.js)");
- var message, message2;
-
- 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.");
- horizon.clearAllMessages();
- 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.');
-
- message2 = horizon.alert("success", "Another message");
- 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.");
- 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.");
- });
-
- test("Alert With HTML Tag", function () {
- var safeString = "A safe message here!";
- message = horizon.alert("success", safeString, "safe");
- ok(message, "Create a message with extra tag.");
- 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.");
- });
-});
diff --git a/horizon/static/horizon/tests/modals.js b/horizon/static/horizon/tests/modals.js
deleted file mode 100644
index 36e068cf1d..0000000000
--- a/horizon/static/horizon/tests/modals.js
+++ /dev/null
@@ -1,25 +0,0 @@
-horizon.addInitFunction(function () {
- module("Modals (horizon.modals.js)");
-
- test("Modal Creation", function () {
- var modal;
- var title = "Test Title";
- var body = "
Test Body
";
- var confirm = "Test Confirm";
- modal = horizon.modals.create(title, body, confirm);
- ok(modal, "Verify our modal was created.");
-
- modal = $("#modal_wrapper .modal");
- 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.");
- modal.find(".modal-footer .cancel").click();
- ok(!modal.hasClass("in"), "Verify our modal is hidden.");
- });
-});
diff --git a/horizon/static/horizon/tests/tables.js b/horizon/static/horizon/tests/tables.js
deleted file mode 100644
index d5c325aa96..0000000000
--- a/horizon/static/horizon/tests/tables.js
+++ /dev/null
@@ -1,115 +0,0 @@
-module("Tables (horizon.tables.js)");
-
-test("Row filtering (fixed)", function () {
- var fixture = $("#qunit-fixture");
- var table = fixture.find("#table2");
-
- ok(!table.find(".cat").is(":hidden"), "Filtering cats: cats visible by default");
- ok(table.find(":not(.cat)").is(":hidden"), "Filtering cats: non-cats hidden by default");
-
- $("#button_cats").trigger("click");
- ok(!table.find(".cat").is(":hidden"), "Filtering cats: cats visible");
- ok(table.find(":not(.cat)").is(":hidden"), "Filtering cats: non-cats hidden");
-
- $("#button_dogs").trigger("click");
- ok(!table.find(".dog").is(":hidden"), "Filtering dogs: dogs visible");
- ok(table.find(":not(.dog)").is(":hidden"), "Filtering dogs: non-dogs hidden");
-
- $("#button_big").trigger("click");
- ok(!table.find(".big").is(":hidden"), "Filtering big animals: big visible");
- ok(table.find(":not(.big)").is(":hidden"), "Filtering big animals: non-big hidden");
-});
-
-test("Footer count update", function () {
- var fixture = $("#qunit-fixture");
- var table = fixture.find("#table1");
- var tbody = table.find('tbody');
- var tableCount = table.find("span.table_count");
- var rows = tbody.find('tr');
-
- // The following function returns the first set of consecutive numbers.
- // This is allows you to match an inner numeric value regardless of
- // the language and regardless of placement within the phrase.
- // 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 getConsecNums = function(str) { return (str.match(/\d+/) || [""])[0]; };
-
- horizon.datatables.update_footer_count(table);
- 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(getConsecNums(tableCount.text()), '2', "Count correct after hiding two rows");
-
- // show a row
- rows.first().next().show();
- horizon.datatables.update_footer_count(table);
- equal(getConsecNums(tableCount.text()), '3', "Count correct after showing one row");
-
- // add rows
- $('
cat3
"').appendTo(tbody);
- $('
cat4
"').appendTo(tbody);
- horizon.datatables.update_footer_count(table);
- equal(getConsecNums(tableCount.text()), '5', "Count correct after adding two rows");
-});
-
-test("Formset reenumerate rows", function () {
- var html = $('#formset');
- var table = html.find('table');
- var input = table.find('tbody tr#flavors__row__14 input').first();
-
- input.attr('id', 'id_flavors-3-name');
- horizon.formset_table.reenumerate_rows(table, 'flavors');
- equal(input.attr('id'), 'id_flavors-0-name', "Enumerate old rows ids");
- input.attr('id', 'id_flavors-__prefix__-name');
- horizon.formset_table.reenumerate_rows(table, 'flavors');
- equal(input.attr('id'), 'id_flavors-0-name', "Enumerate new rows ids");
-});
-
-test("Formset delete row", function () {
- var html = $('#formset');
- var table = html.find('table');
- var row = table.find('tbody tr').first();
- var input = row.find('input#id_flavors-0-DELETE');
-
- equal(row.css("display"), 'table-row');
- equal(input.attr('checked'), undefined);
- horizon.formset_table.replace_delete(row);
- var x = input.next('a');
- horizon.formset_table.delete_row.call(x);
- equal(row.css("display"), 'none');
- equal(input.attr('checked'), 'checked');
-});
-
-test("Formset add row", function() {
- var html = $('#formset');
- var table = html.find('table');
- var emptyRowHtml = '
';
-
- equal(table.find('tbody tr').length, 3);
- equal(html.find('#id_flavors-TOTAL_FORMS').val(), 3);
- 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);
-});
-
-test("Init formset table", function() {
- var html = $('#formset');
- var table = html.find('table');
-
- horizon.formset_table.init('flavors', '', 'Add row');
- equal(table.find('tfoot tr a').html(), 'Add row');
-});
-
-test("Init formset table -- no add", function() {
- var html = $('#formset');
- var table = html.find('table');
-
- horizon.formset_table.init('flavors', '', '');
- equal(table.find('tfoot tr a').length, 0);
-});
diff --git a/horizon/static/horizon/tests/templates.js b/horizon/static/horizon/tests/templates.js
deleted file mode 100644
index e36bec36d7..0000000000
--- a/horizon/static/horizon/tests/templates.js
+++ /dev/null
@@ -1,11 +0,0 @@
-horizon.addInitFunction(function () {
- module("Client-Side Templating (horizon.templates.js)");
-
- test("Template Compilation", function () {
- var size = 0;
- angular.forEach(horizon.templates.compiled_templates, function () {
- size = size + 1;
- });
- ok(size > 0, "Compiled templates list should not be empty.");
- });
-});
diff --git a/horizon/templates/horizon/jasmine/jasmine.html b/horizon/templates/horizon/jasmine/jasmine.html
index 1e20df6aa1..963335b5ca 100644
--- a/horizon/templates/horizon/jasmine/jasmine.html
+++ b/horizon/templates/horizon/jasmine/jasmine.html
@@ -40,10 +40,15 @@
+ {% block source %}
+ {% endblock %}
+
- {% for file in HORIZON_CONFIG.js_spec_files %}
-
- {% endfor %}
+ {% block spec %}
+ {% for file in HORIZON_CONFIG.js_spec_files %}
+
+ {% endfor %}
+ {% endblock %}
diff --git a/horizon/templates/horizon/qunit.html b/horizon/templates/horizon/jasmine/jasmine_legacy.html
similarity index 78%
rename from horizon/templates/horizon/qunit.html
rename to horizon/templates/horizon/jasmine/jasmine_legacy.html
index 49e99d1eb5..932ced5d9b 100644
--- a/horizon/templates/horizon/qunit.html
+++ b/horizon/templates/horizon/jasmine/jasmine_legacy.html
@@ -1,31 +1,43 @@
-
-
-
-
- Horizon QUnit Test Suite
-
-
-
- {% include "horizon/_conf.html" %}
+{% extends "horizon/jasmine/jasmine.html" %}
- {% comment %}Load test modules here.{% endcomment %}
-
-
-
-
- {% comment %}End test modules.{% endcomment %}
+{% block source %}
+
+ {% include "horizon/_script_i18n.html" %}
- {% include "horizon/_scripts.html" %}
-
-
-