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
6db1be6e
Commit
6db1be6e
authored
Aug 06, 2013
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add jasmine tests to verify link rewriting in HTML editor
parent
7a180c29
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
common/lib/xmodule/xmodule/js/fixtures/html-edit-with-links.html
+11
-0
common/lib/xmodule/xmodule/js/spec/html/edit_spec.coffee
+31
-0
No files found.
common/lib/xmodule/xmodule/js/fixtures/html-edit-with-links.html
0 → 100644
View file @
6db1be6e
<section
class=
"html-edit"
>
<ul
class=
"editor-tabs"
>
<li><a
href=
"#"
class=
"visual-tab tab current"
data-tab=
"visual"
>
Visual
</a></li>
<li><a
href=
"#"
class=
"html-tab tab"
data-tab=
"advanced"
>
HTML
</a></li>
</ul>
<div
class=
"row"
>
<textarea
class=
"tiny-mce"
>
dummy text
</textarea>
<textarea
name=
""
class=
"edit-box"
>
Advanced Editor Text with link /static/dummy.jpg
</textarea>
</div>
</section>
\ No newline at end of file
common/lib/xmodule/xmodule/js/spec/html/edit_spec.coffee
View file @
6db1be6e
...
...
@@ -48,6 +48,16 @@ describe 'HTMLEditingDescriptor', ->
expect
(
@
descriptor
.
showingVisualEditor
).
toEqual
(
true
)
data
=
@
descriptor
.
save
().
data
expect
(
data
).
toEqual
(
'from visual editor'
)
it
'Performs link rewriting for static assets when saving'
,
->
visualEditorStub
=
isDirty
:
()
->
true
getContent
:
()
->
'from visual editor with /c4x/foo/bar/asset/image.jpg'
spyOn
(
@
descriptor
,
'getVisualEditor'
).
andCallFake
()
->
visualEditorStub
expect
(
@
descriptor
.
showingVisualEditor
).
toEqual
(
true
)
@
descriptor
.
base_asset_url
=
'/c4x/foo/bar/asset/'
data
=
@
descriptor
.
save
().
data
expect
(
data
).
toEqual
(
'from visual editor with /static/image.jpg'
)
describe
'Can switch to Advanced Editor'
,
->
beforeEach
->
loadFixtures
'html-edit.html'
...
...
@@ -88,3 +98,23 @@ describe 'HTMLEditingDescriptor', ->
expect
(
visualEditorStub
.
isDirty
()).
toEqual
(
false
)
expect
(
visualEditorStub
.
getContent
()).
toEqual
(
'Advanced Editor Text'
)
expect
(
visualEditorStub
.
startContent
).
toEqual
(
'Advanced Editor Text'
)
it
'When switching to Advanced Editors links are rewritten to c4x format'
,
->
loadFixtures
'html-edit-with-links.html'
@
descriptor
=
new
HTMLEditingDescriptor
(
$
(
'.html-edit'
))
@
descriptor
.
base_asset_url
=
'/c4x/foo/bar/asset/'
@
descriptor
.
showingVisualEditor
=
false
visualEditorStub
=
isNotDirty
:
false
content
:
'not set'
startContent
:
'not set'
,
focus
:
()
->
true
isDirty
:
()
->
not
@
isNotDirty
setContent
:
(
x
)
->
@
content
=
x
getContent
:
->
@
content
@
descriptor
.
showVisualEditor
(
visualEditorStub
)
expect
(
@
descriptor
.
showingVisualEditor
).
toEqual
(
true
)
expect
(
visualEditorStub
.
isDirty
()).
toEqual
(
false
)
expect
(
visualEditorStub
.
getContent
()).
toEqual
(
'Advanced Editor Text with link /c4x/foo/bar/asset/dummy.jpg'
)
expect
(
visualEditorStub
.
startContent
).
toEqual
(
'Advanced Editor Text with link /c4x/foo/bar/asset/dummy.jpg'
)
\ No newline at end of file
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