diff options
author | Code Raguet <ignacio.code@gmail.com> | 2013-07-26 16:44:42 (GMT) |
---|---|---|
committer | Code Raguet <ignacio.code@gmail.com> | 2013-07-26 16:44:42 (GMT) |
commit | 6afdf12f096bcb0d6a1acdbed26d137f6d540a45 (patch) | |
tree | c620d69b7621ec544e94d07a31450215c964015c | |
parent | 65a3e46a8286b56c144a00a6ef136eab664313e3 (diff) |
Refactor: move Fields describe spec to his own file
-rw-r--r-- | webapp/js_tests/spec/DynamicStructureSpec.js | 281 | ||||
-rw-r--r-- | webapp/js_tests/spec/FieldsSpec.js | 280 |
2 files changed, 280 insertions, 281 deletions
diff --git a/webapp/js_tests/spec/DynamicStructureSpec.js b/webapp/js_tests/spec/DynamicStructureSpec.js index f35a93d..8b5c84b 100644 --- a/webapp/js_tests/spec/DynamicStructureSpec.js +++ b/webapp/js_tests/spec/DynamicStructureSpec.js @@ -159,285 +159,4 @@ describe("", function() { }); - describe("Fields", function() { - - beforeEach(function() { - - jasmine.getFixtures().fixturesPath = "fixtures/"; - loadFixtures("container.html"); - - var field_mustache_template = $.ajax({ - type: "GET", - url: '/jasmine/mustache_templates/field.html', - cache: false, - async: false - }).responseText; - $("#jasmine-fixtures").append(field_mustache_template); - - Mustache.tags = ['[[', ']]']; - - // Preparing mustache TEMPLATES - $('script[type="text/x-mustache-template"]').each(function(i, obj){ - TEMPLATES[$(obj).attr('name')] = $(obj).text(); - }); - - }); - - it("- Field template must contains right classes", function() { - var field_template = $(TEMPLATES['field']); - - var field_remove_button = field_template.find('.WField_remove'); - expect(field_remove_button).toExist(); - expect(field_remove_button).toBe(':button'); - - expect(field_template.find('.error')).toExist(); - - expect(field_template.find('.WFieldWidgetType')).toExist(); - - expect(field_template.find('.WFieldAddOptionButton_container')).toExist(); - - expect(field_template.find('.WFieldOptions_container')).toExist(); - }); - - it("Second option must has greater order than firt option", function() { - - // Preparing mustache TEMPLATES - var option_mustache_template = $.ajax({ - type: "GET", - url: '/jasmine/mustache_templates/option.html', - cache: false, - async: false - }).responseText; - $("#jasmine-fixtures").append(option_mustache_template); - - $('script[type="text/x-mustache-template"]').each(function(i, obj){ - TEMPLATES[$(obj).attr('name')] = $(obj).text(); - }); - - factoryField("0", {"container": container, "widget_type": "MultipleCheckBox"}); - - var field_widget = container.children(); - var field_add_option_button = $(field_widget.find('.WFieldOptions_add_button')); - field_add_option_button = field_add_option_button.find('button'); - field_add_option_button.click(); - var first_option = $(field_widget.find(".WFieldOptions_container .row-fluid")[0]); - - var field_widget = container.children(); - var field_add_option_button = $(field_widget.find('.WFieldOptions_add_button')); - field_add_option_button = field_add_option_button.find('button'); - field_add_option_button.click(); - var second_option = $(field_widget.find(".WFieldOptions_container .row-fluid")[1]); - - var first_option_order = $(first_option.find("[name*='.order']")[0]).val(); - var second_option_order = $(second_option.find("[name*='.order']")[0]).val(); - - expect( first_option_order ).toBeLessThan( second_option_order ); - - }); - - describe("Options except TextInput and image widget types", function() { - - it("option widget has an order", function() { - - jasmine.getFixtures().fixturesPath = "fixtures/"; - loadFixtures("container.html"); - - var option_mustache_template = $.ajax({ - type: "GET", - url: '/jasmine/mustache_templates/option.html', - cache: false, - async: false - }).responseText; - $("#jasmine-fixtures").append(option_mustache_template); - - Mustache.tags = ['[[', ']]']; - - // Preparing mustache TEMPLATES - $('script[type="text/x-mustache-template"]').each(function(i, obj){ - TEMPLATES[$(obj).attr('name')] = $(obj).text(); - }); - - factoryOption("1", "", container, "0", "0"); - - options = container.children(); - - option_1_order = options.find( - "[name='groups.0.fields.0.options.1.order']")[0]; - - expect(option_1_order).not.toBeUndefined(); - - }); - - }); - - describe("Option none", function() { - - it("should have a none attribute with value True", function() { - - jasmine.getFixtures().fixturesPath = "fixtures/"; - loadFixtures("container.html"); - - var option_mustache_template = $.ajax({ - type: "GET", - url: '/jasmine/mustache_templates/option.html', - cache: false, - async: false - }).responseText; - $("#jasmine-fixtures").append(option_mustache_template); - - Mustache.tags = ['[[', ']]']; - - // Preparing mustache TEMPLATES - $('script[type="text/x-mustache-template"]').each(function(i, obj){ - TEMPLATES[$(obj).attr('name')] = $(obj).text(); - }); - - factoryOption("1", {none: 'True'}, container, "0", "0"); - - options = container.children(); - option_1_none = options.find( - "[name='groups.0.fields.0.options.1.none']")[0]; - - expect(option_1_none).not.toBeUndefined(); - expect($(option_1_none).val()).toBe('True'); - - }); - - }); - - describe("TextInput widget type options", function() { - - it("option widget has an order", function() { - - jasmine.getFixtures().fixturesPath = "fixtures/"; - loadFixtures("container.html"); - - var option_default_mustache_template = $.ajax({ - type: "GET", - url: '/jasmine/mustache_templates/option_default.html', - cache: false, - async: false - }).responseText; - $("#jasmine-fixtures").append(option_default_mustache_template); - - Mustache.tags = ['[[', ']]']; - - // Preparing mustache TEMPLATES - $('script[type="text/x-mustache-template"]').each(function(i, obj){ - TEMPLATES[$(obj).attr('name')] = $(obj).text(); - }); - - factoryField("0", {"container": container, "widget_type": "TextInput"}); - - var field_widget = container.children(); - - factoryOptionDefault("0", field_widget, "1", ""); - - options = container.children(); - - option_1_order = options.find( - "[name='groups.0.fields.0.options.1.order']")[0]; - - expect(option_1_order).not.toBeUndefined(); - - expect($(option_1_order).val()).toBe("0"); - - }); - - }); - - describe("Image thumbnail widget type options", function() { - - it("option widget has an order", function() { - - jasmine.getFixtures().fixturesPath = "fixtures/"; - loadFixtures("container.html"); - - var option_image_thumbnail_mustache_template = $.ajax({ - type: "GET", - url: '/jasmine/mustache_templates/option_image_thumbnail.html', - cache: false, - async: false - }).responseText; - $("#jasmine-fixtures").append(option_image_thumbnail_mustache_template); - - Mustache.tags = ['[[', ']]']; - - // Preparing mustache TEMPLATES - $('script[type="text/x-mustache-template"]').each(function(i, obj){ - TEMPLATES[$(obj).attr('name')] = $(obj).text(); - }); - - factoryField("0", {"container": container, "widget_type": "ImageCheckBox"}); - - var field_widget = container.children(); - - jQuery.fn.popover = function(){}; - - factoryImageOptionThumbnail("1", {}, container, "0", "0", "0"); - - options = container.children(); - - option_1_order = options.find( - "[name='groups.0.fields.0.options.1.order']")[0]; - - expect(option_1_order).not.toBeUndefined(); - - expect($(option_1_order).val()).toBe("0"); - - }); - - }); - - describe("Image upload widget type options", function() { - - beforeEach(function() { - - jasmine.getFixtures().fixturesPath = "fixtures/"; - loadFixtures("container.html"); - - var option_mustache_template = $.ajax({ - type: "GET", - url: '/jasmine/mustache_templates/option.html', - cache: false, - async: false - }).responseText; - $("#jasmine-fixtures").append(option_mustache_template); - - var option_image_upload_mustache_template = $.ajax({ - type: "GET", - url: '/jasmine/mustache_templates/option_image_upload.html', - cache: false, - async: false - }).responseText; - $("#jasmine-fixtures").append(option_image_upload_mustache_template); - - Mustache.tags = ['[[', ']]']; - - // Preparing mustache TEMPLATES - $('script[type="text/x-mustache-template"]').each(function(i, obj){ - TEMPLATES[$(obj).attr('name')] = $(obj).text(); - }); - - }); - - it("option widget has an order", function() { - - factoryImageOptionUpload("1", {}, container, "0", "0", "0"); - - options = container.children(); - - option_1_order = options.find( - "[name='groups.0.fields.0.options.1.order']")[0]; - - expect(option_1_order).not.toBeUndefined(); - - expect($(option_1_order).val()).toBe("0"); - - }); - - }); - - }); - });
\ No newline at end of file diff --git a/webapp/js_tests/spec/FieldsSpec.js b/webapp/js_tests/spec/FieldsSpec.js new file mode 100644 index 0000000..c143d1a --- /dev/null +++ b/webapp/js_tests/spec/FieldsSpec.js @@ -0,0 +1,280 @@ +describe("Fields", function() { + + beforeEach(function() { + + jasmine.getFixtures().fixturesPath = "fixtures/"; + loadFixtures("container.html"); + + var field_mustache_template = $.ajax({ + type: "GET", + url: '/jasmine/mustache_templates/field.html', + cache: false, + async: false + }).responseText; + $("#jasmine-fixtures").append(field_mustache_template); + + Mustache.tags = ['[[', ']]']; + + // Preparing mustache TEMPLATES + $('script[type="text/x-mustache-template"]').each(function(i, obj){ + TEMPLATES[$(obj).attr('name')] = $(obj).text(); + }); + + }); + + it("- Field template must contains right classes", function() { + var field_template = $(TEMPLATES['field']); + + var field_remove_button = field_template.find('.WField_remove'); + expect(field_remove_button).toExist(); + expect(field_remove_button).toBe(':button'); + + expect(field_template.find('.error')).toExist(); + + expect(field_template.find('.WFieldWidgetType')).toExist(); + + expect(field_template.find('.WFieldAddOptionButton_container')).toExist(); + + expect(field_template.find('.WFieldOptions_container')).toExist(); + }); + + it("Second option must has greater order than firt option", function() { + + // Preparing mustache TEMPLATES + var option_mustache_template = $.ajax({ + type: "GET", + url: '/jasmine/mustache_templates/option.html', + cache: false, + async: false + }).responseText; + $("#jasmine-fixtures").append(option_mustache_template); + + $('script[type="text/x-mustache-template"]').each(function(i, obj){ + TEMPLATES[$(obj).attr('name')] = $(obj).text(); + }); + + factoryField("0", {"container": container, "widget_type": "MultipleCheckBox"}); + + var field_widget = container.children(); + var field_add_option_button = $(field_widget.find('.WFieldOptions_add_button')); + field_add_option_button = field_add_option_button.find('button'); + field_add_option_button.click(); + var first_option = $(field_widget.find(".WFieldOptions_container .row-fluid")[0]); + + var field_widget = container.children(); + var field_add_option_button = $(field_widget.find('.WFieldOptions_add_button')); + field_add_option_button = field_add_option_button.find('button'); + field_add_option_button.click(); + var second_option = $(field_widget.find(".WFieldOptions_container .row-fluid")[1]); + + var first_option_order = $(first_option.find("[name*='.order']")[0]).val(); + var second_option_order = $(second_option.find("[name*='.order']")[0]).val(); + + expect( first_option_order ).toBeLessThan( second_option_order ); + + }); + + describe("Options except TextInput and image widget types", function() { + + it("option widget has an order", function() { + + jasmine.getFixtures().fixturesPath = "fixtures/"; + loadFixtures("container.html"); + + var option_mustache_template = $.ajax({ + type: "GET", + url: '/jasmine/mustache_templates/option.html', + cache: false, + async: false + }).responseText; + $("#jasmine-fixtures").append(option_mustache_template); + + Mustache.tags = ['[[', ']]']; + + // Preparing mustache TEMPLATES + $('script[type="text/x-mustache-template"]').each(function(i, obj){ + TEMPLATES[$(obj).attr('name')] = $(obj).text(); + }); + + factoryOption("1", "", container, "0", "0"); + + options = container.children(); + + option_1_order = options.find( + "[name='groups.0.fields.0.options.1.order']")[0]; + + expect(option_1_order).not.toBeUndefined(); + + }); + + }); + + describe("Option none", function() { + + it("should have a none attribute with value True", function() { + + jasmine.getFixtures().fixturesPath = "fixtures/"; + loadFixtures("container.html"); + + var option_mustache_template = $.ajax({ + type: "GET", + url: '/jasmine/mustache_templates/option.html', + cache: false, + async: false + }).responseText; + $("#jasmine-fixtures").append(option_mustache_template); + + Mustache.tags = ['[[', ']]']; + + // Preparing mustache TEMPLATES + $('script[type="text/x-mustache-template"]').each(function(i, obj){ + TEMPLATES[$(obj).attr('name')] = $(obj).text(); + }); + + factoryOption("1", {none: 'True'}, container, "0", "0"); + + options = container.children(); + option_1_none = options.find( + "[name='groups.0.fields.0.options.1.none']")[0]; + + expect(option_1_none).not.toBeUndefined(); + expect($(option_1_none).val()).toBe('True'); + + }); + + }); + + describe("TextInput widget type options", function() { + + it("option widget has an order", function() { + + jasmine.getFixtures().fixturesPath = "fixtures/"; + loadFixtures("container.html"); + + var option_default_mustache_template = $.ajax({ + type: "GET", + url: '/jasmine/mustache_templates/option_default.html', + cache: false, + async: false + }).responseText; + $("#jasmine-fixtures").append(option_default_mustache_template); + + Mustache.tags = ['[[', ']]']; + + // Preparing mustache TEMPLATES + $('script[type="text/x-mustache-template"]').each(function(i, obj){ + TEMPLATES[$(obj).attr('name')] = $(obj).text(); + }); + + factoryField("0", {"container": container, "widget_type": "TextInput"}); + + var field_widget = container.children(); + + factoryOptionDefault("0", field_widget, "1", ""); + + options = container.children(); + + option_1_order = options.find( + "[name='groups.0.fields.0.options.1.order']")[0]; + + expect(option_1_order).not.toBeUndefined(); + + expect($(option_1_order).val()).toBe("0"); + + }); + + }); + + describe("Image thumbnail widget type options", function() { + + it("option widget has an order", function() { + + jasmine.getFixtures().fixturesPath = "fixtures/"; + loadFixtures("container.html"); + + var option_image_thumbnail_mustache_template = $.ajax({ + type: "GET", + url: '/jasmine/mustache_templates/option_image_thumbnail.html', + cache: false, + async: false + }).responseText; + $("#jasmine-fixtures").append(option_image_thumbnail_mustache_template); + + Mustache.tags = ['[[', ']]']; + + // Preparing mustache TEMPLATES + $('script[type="text/x-mustache-template"]').each(function(i, obj){ + TEMPLATES[$(obj).attr('name')] = $(obj).text(); + }); + + factoryField("0", {"container": container, "widget_type": "ImageCheckBox"}); + + var field_widget = container.children(); + + jQuery.fn.popover = function(){}; + + factoryImageOptionThumbnail("1", {}, container, "0", "0", "0"); + + options = container.children(); + + option_1_order = options.find( + "[name='groups.0.fields.0.options.1.order']")[0]; + + expect(option_1_order).not.toBeUndefined(); + + expect($(option_1_order).val()).toBe("0"); + + }); + + }); + + describe("Image upload widget type options", function() { + + beforeEach(function() { + + jasmine.getFixtures().fixturesPath = "fixtures/"; + loadFixtures("container.html"); + + var option_mustache_template = $.ajax({ + type: "GET", + url: '/jasmine/mustache_templates/option.html', + cache: false, + async: false + }).responseText; + $("#jasmine-fixtures").append(option_mustache_template); + + var option_image_upload_mustache_template = $.ajax({ + type: "GET", + url: '/jasmine/mustache_templates/option_image_upload.html', + cache: false, + async: false + }).responseText; + $("#jasmine-fixtures").append(option_image_upload_mustache_template); + + Mustache.tags = ['[[', ']]']; + + // Preparing mustache TEMPLATES + $('script[type="text/x-mustache-template"]').each(function(i, obj){ + TEMPLATES[$(obj).attr('name')] = $(obj).text(); + }); + + }); + + it("option widget has an order", function() { + + factoryImageOptionUpload("1", {}, container, "0", "0", "0"); + + options = container.children(); + + option_1_order = options.find( + "[name='groups.0.fields.0.options.1.order']")[0]; + + expect(option_1_order).not.toBeUndefined(); + + expect($(option_1_order).val()).toBe("0"); + + }); + + }); + +});
\ No newline at end of file |