Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
a1cb0a12
Commit
a1cb0a12
authored
Jan 22, 2014
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Define fixtures outside of the beforeEach.
parent
b5726a68
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
45 deletions
+43
-45
cms/static/js/spec/views/unit_spec.js
+43
-45
No files found.
cms/static/js/spec/views/unit_spec.js
View file @
a1cb0a12
...
...
@@ -27,31 +27,30 @@ define(["coffee/src/views/unit", "js/models/module_info", "js/spec/create_sinon"
};
describe
(
'duplicateComponent '
,
function
()
{
var
duplicateFixture
=
'<div class="main-wrapper edit-state-draft" data-locator="unit_locator">
\
<ol class="components">
\
<li class="component" data-locator="loc_1">
\
<div class="wrapper wrapper-component-editor"/>
\
<div class="component-actions">
\
<a href="#" class="duplicate-button standard"><span class="duplicate-icon icon-copy"></span>Duplicate</a>
\
</div>
\
</li>
\
<li class="component" data-locator="loc_2">
\
<div class="wrapper wrapper-component-editor"/>
\
<div class="component-actions">
\
<a href="#" class="duplicate-button standard"><span class="duplicate-icon icon-copy"></span>Duplicate</a>
\
</div>
\
</li>
\
</ol>
\
</div>'
;
var
unit
;
var
clickDuplicate
=
function
(
index
)
{
unit
.
$
(
".duplicate-button"
)[
index
].
click
();
};
beforeEach
(
function
()
{
setFixtures
(
'<div class="main-wrapper edit-state-draft" data-locator="unit_locator">
\
<ol class="components">
\
<li class="component" data-locator="loc_1">
\
<div class="wrapper wrapper-component-editor">
\
</div>
\
<div class="component-actions">
\
<a href="#" class="duplicate-button standard"><span class="duplicate-icon icon-copy"></span>Duplicate</a>
\
</div>
\
</li>
\
<li class="component" data-locator="loc_2">
\
<div class="wrapper wrapper-component-editor">
\
</div>
\
<div class="component-actions">
\
<a href="#" class="duplicate-button standard"><span class="duplicate-icon icon-copy"></span>Duplicate</a>
\
</div>
\
</li>
\
</ol>
\
'
);
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 duplicate
d'
,
function
()
{
it
(
'inserts duplicated component at end if
source at en
d'
,
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
=
'<div class="main-wrapper edit-state-draft" data-locator="unit_locator">
\
<ol class="components">
\
<li class="component" data-locator="loc_1">
\
<div class="wrapper wrapper-component-editor"/>
\
</li>
\
<li class="component" data-locator="loc_2">
\
<div class="wrapper wrapper-component-editor"/>
\
</li>
\
<li class="new-component-item adding">
\
<div class="new-component">
\
<ul class="new-component-type">
\
<li>
\
<a href="#" class="single-template" data-type="discussion" data-category="discussion"/>
\
</li>
\
</ul>
\
</div>
\
</li>
\
</ol>
\
</div>'
;
var
unit
;
var
clickNewComponent
=
function
()
{
unit
.
$
(
".new-component .new-component-type a.single-template"
).
click
();
};
beforeEach
(
function
()
{
setFixtures
(
'<div class="main-wrapper edit-state-draft" data-locator="unit_locator">
\
<ol class="components">
\
<li class="component" data-locator="loc_1">
\
<div class="wrapper wrapper-component-editor">
\
</div>
\
</li>
\
<li class="component" data-locator="loc_2">
\
<div class="wrapper wrapper-component-editor">
\
</div>
\
</li>
\
<li class="new-component-item adding">
\
<div class="new-component">
\
<ul class="new-component-type">
\
<li>
\
<a href="#" class="single-template" data-type="discussion" data-category="discussion"/>
\
</li>
\
</ul>
\
</div>
\
</li>
\
</ol>
\
'
);
setFixtures
(
newComponentFixture
);
unit
=
new
UnitEditView
({
el
:
$
(
'.main-wrapper'
),
model
:
new
ModuleModel
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment