From a1cb0a128b41dc56d75f5d8bfe05f6eaa689ada8 Mon Sep 17 00:00:00 2001 From: cahrens Date: Wed, 22 Jan 2014 11:01:19 -0500 Subject: [PATCH] Define fixtures outside of the beforeEach. --- cms/static/js/spec/views/unit_spec.js | 88 +++++++++++++-------------- 1 file changed, 43 insertions(+), 45 deletions(-) diff --git a/cms/static/js/spec/views/unit_spec.js b/cms/static/js/spec/views/unit_spec.js index 08dbffd96d..189b935eda 100644 --- a/cms/static/js/spec/views/unit_spec.js +++ b/cms/static/js/spec/views/unit_spec.js @@ -27,31 +27,30 @@ define(["coffee/src/views/unit", "js/models/module_info", "js/spec/create_sinon" }; describe('duplicateComponent ', function () { + var duplicateFixture = + '
\ +
    \ +
  1. \ +
    \ +
    \ + Duplicate \ +
    \ +
  2. \ +
  3. \ +
    \ +
    \ + Duplicate \ +
    \ +
  4. \ +
\ +
'; + var unit; var clickDuplicate = function (index) { unit.$(".duplicate-button")[index].click(); }; beforeEach(function () { - setFixtures( - '
\ -
    \ -
  1. \ -
    \ -
    \ -
    \ - Duplicate \ -
    \ -
  2. \ -
  3. \ -
    \ -
    \ -
    \ - Duplicate \ -
    \ -
  4. \ -
\ - ' - ); + setFixtures(duplicateFixture); unit = new UnitEditView({ el: $('.main-wrapper'), model: new ModuleModel({ @@ -67,14 +66,14 @@ define(["coffee/src/views/unit", "js/models/module_info", "js/spec/create_sinon" verifyJSON(requests, '{"duplicate_source_locator":"loc_1","parent_locator":"unit_locator"}'); }); - it('inserts duplicated component immediately after source upon success and shows notification', function () { + it('inserts duplicated component immediately after source upon success', function () { var requests = create_sinon.requests(this); clickDuplicate(0); create_sinon.respondWithJson(requests, {"locator": "duplicated_item"}); verifyComponents(unit, ['loc_1', 'duplicated_item', 'loc_2']); }); - it('inserts duplicated component at end if last duplicated', function () { + it('inserts duplicated component at end if source at end', function () { var requests = create_sinon.requests(this); clickDuplicate(1); create_sinon.respondWithJson(requests, {"locator": "duplicated_item"}); @@ -98,34 +97,33 @@ define(["coffee/src/views/unit", "js/models/module_info", "js/spec/create_sinon" }); }); describe('saveNewComponent ', function () { + var newComponentFixture = + '
\ +
    \ +
  1. \ +
    \ +
  2. \ +
  3. \ +
    \ +
  4. \ +
  5. \ +
    \ + \ +
    \ +
  6. \ +
\ +
'; + var unit; var clickNewComponent = function () { unit.$(".new-component .new-component-type a.single-template").click(); }; beforeEach(function () { - setFixtures( - '