Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
43dc6263
Commit
43dc6263
authored
Jan 24, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run tests in a single browser session
parent
79440890
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
66 deletions
+81
-66
spec/features/copy_as_gfm_spec.rb
spec/features/copy_as_gfm_spec.rb
+81
-66
No files found.
spec/features/copy_as_gfm_spec.rb
View file @
43dc6263
...
@@ -18,12 +18,18 @@ describe 'Copy as GFM', feature: true, js: true do
...
@@ -18,12 +18,18 @@ describe 'Copy as GFM', feature: true, js: true do
# To make sure these filters and handlers are properly aligned, this spec tests the GFM-to-HTML-to-GFM cycle
# To make sure these filters and handlers are properly aligned, this spec tests the GFM-to-HTML-to-GFM cycle
# by verifying (`html_to_gfm(gfm_to_html(gfm)) == gfm`) for a number of examples of GFM for every filter, using the `verify` helper.
# by verifying (`html_to_gfm(gfm_to_html(gfm)) == gfm`) for a number of examples of GFM for every filter, using the `verify` helper.
it
'supports nesting'
do
# These are all in a single `it` for performance reasons.
verify
'> 1. [x] **[$`2 + 2`$ {-=-}{+=+} 2^2 ~~:thumbsup:~~](http://google.com)**'
it
'works'
,
:aggregate_failures
do
end
verify
(
'nesting'
,
'> 1. [x] **[$`2 + 2`$ {-=-}{+=+} 2^2 ~~:thumbsup:~~](http://google.com)**'
)
verify
(
'a real world example from the gitlab-ce README'
,
it
'supports a real world example from the gitlab-ce README'
do
<<-
GFM
.
strip_heredoc
verify
<<-
GFM
.
strip_heredoc
# GitLab
# GitLab
[![Build status](https://gitlab.com/gitlab-org/gitlab-ce/badges/master/build.svg)](https://gitlab.com/gitlab-org/gitlab-ce/commits/master)
[![Build status](https://gitlab.com/gitlab-org/gitlab-ce/badges/master/build.svg)](https://gitlab.com/gitlab-org/gitlab-ce/commits/master)
...
@@ -52,26 +58,27 @@ describe 'Copy as GFM', feature: true, js: true do
...
@@ -52,26 +58,27 @@ describe 'Copy as GFM', feature: true, js: true do
- Completely free and open source (MIT Expat license)
- Completely free and open source (MIT Expat license)
GFM
GFM
end
)
it
'supports InlineDiffFilter'
do
verify
(
verify
(
'InlineDiffFilter'
,
'{-Deleted text-}'
,
'{-Deleted text-}'
,
'{+Added text+}'
'{+Added text+}'
)
)
end
it
'supports TaskListFilter'
do
verify
(
verify
(
'TaskListFilter'
,
'- [ ] Unchecked task'
,
'- [ ] Unchecked task'
,
'- [x] Checked task'
,
'- [x] Checked task'
,
'1. [ ] Unchecked numbered task'
,
'1. [ ] Unchecked numbered task'
,
'1. [x] Checked numbered task'
'1. [x] Checked numbered task'
)
)
end
it
'supports ReferenceFilter'
do
verify
(
verify
(
'ReferenceFilter'
,
# issue reference
# issue reference
@feat
.
issue
.
to_reference
,
@feat
.
issue
.
to_reference
,
# full issue reference
# full issue reference
...
@@ -85,31 +92,40 @@ describe 'Copy as GFM', feature: true, js: true do
...
@@ -85,31 +92,40 @@ describe 'Copy as GFM', feature: true, js: true do
# issue link with note anchor
# issue link with note anchor
"[Issue](
#{
namespace_project_issue_url
(
@project
.
namespace
,
@project
,
@feat
.
issue
,
anchor:
'note_123'
)
}
)"
,
"[Issue](
#{
namespace_project_issue_url
(
@project
.
namespace
,
@project
,
@feat
.
issue
,
anchor:
'note_123'
)
}
)"
,
)
)
end
it
'supports AutolinkFilter'
do
verify
(
verify
'https://example.com'
'AutolinkFilter'
,
end
it
'supports TableOfContentsFilter'
do
'https://example.com'
verify
'[[_TOC_]]'
)
end
it
'supports EmojiFilter'
do
verify
(
verify
':thumbsup:'
'TableOfContentsFilter'
,
end
it
'supports ImageLinkFilter'
do
'[[_TOC_]]'
verify
'![Image](https://example.com/image.png)'
)
end
it
'supports VideoLinkFilter'
do
verify
(
verify
'![Video](https://example.com/video.mp4)'
'EmojiFilter'
,
end
':thumbsup:'
)
context
'MathFilter'
do
it
'supports math as converted from GFM to HTML'
do
verify
(
verify
(
'ImageLinkFilter'
,
'![Image](https://example.com/image.png)'
)
verify
(
'VideoLinkFilter'
,
'![Video](https://example.com/video.mp4)'
)
verify
(
'MathFilter: math as converted from GFM to HTML'
,
'$`c = \pm\sqrt{a^2 + b^2}`$'
,
'$`c = \pm\sqrt{a^2 + b^2}`$'
,
# math block
# math block
...
@@ -119,9 +135,8 @@ describe 'Copy as GFM', feature: true, js: true do
...
@@ -119,9 +135,8 @@ describe 'Copy as GFM', feature: true, js: true do
```
```
GFM
GFM
)
)
end
it
'supports math as transformed from HTML to KaTeX'
do
aggregate_failures
(
'MathFilter: math as transformed from HTML to KaTeX'
)
do
gfm
=
'$`c = \pm\sqrt{a^2 + b^2}`$'
gfm
=
'$`c = \pm\sqrt{a^2 + b^2}`$'
html
=
<<-
HTML
.
strip_heredoc
html
=
<<-
HTML
.
strip_heredoc
...
@@ -231,10 +246,10 @@ describe 'Copy as GFM', feature: true, js: true do
...
@@ -231,10 +246,10 @@ describe 'Copy as GFM', feature: true, js: true do
output_gfm
=
html_to_gfm
(
html
)
output_gfm
=
html_to_gfm
(
html
)
expect
(
output_gfm
.
strip
).
to
eq
(
gfm
.
strip
)
expect
(
output_gfm
.
strip
).
to
eq
(
gfm
.
strip
)
end
end
end
it
'supports SanitizationFilter'
do
verify
(
verify
(
'SanitizationFilter'
,
<<-
GFM
.
strip_heredoc
<<-
GFM
.
strip_heredoc
<sub>sub</sub>
<sub>sub</sub>
...
@@ -260,10 +275,10 @@ describe 'Copy as GFM', feature: true, js: true do
...
@@ -260,10 +275,10 @@ describe 'Copy as GFM', feature: true, js: true do
<abbr>abbr</abbr>
<abbr>abbr</abbr>
GFM
GFM
)
)
end
it
'supports SyntaxHighlightFilter'
do
verify
(
verify
(
'SanitizationFilter'
,
<<-
GFM
.
strip_heredoc
,
<<-
GFM
.
strip_heredoc
,
```
```
Plain text
Plain text
...
@@ -288,10 +303,10 @@ describe 'Copy as GFM', feature: true, js: true do
...
@@ -288,10 +303,10 @@ describe 'Copy as GFM', feature: true, js: true do
```
```
GFM
GFM
)
)
end
it
'supports MarkdownFilter'
do
verify
(
verify
(
'MarkdownFilter'
,
"Line with two spaces at the end
\n
to insert a linebreak"
,
"Line with two spaces at the end
\n
to insert a linebreak"
,
'`code`'
,
'`code`'
,
...
@@ -400,8 +415,8 @@ describe 'Copy as GFM', feature: true, js: true do
...
@@ -400,8 +415,8 @@ describe 'Copy as GFM', feature: true, js: true do
page
.
evaluate_script
(
js
)
page
.
evaluate_script
(
js
)
end
end
def
verify
(
*
gfms
)
def
verify
(
label
,
*
gfms
)
aggregate_failures
do
aggregate_failures
(
label
)
do
gfms
.
each
do
|
gfm
|
gfms
.
each
do
|
gfm
|
html
=
gfm_to_html
(
gfm
)
html
=
gfm_to_html
(
gfm
)
output_gfm
=
html_to_gfm
(
html
)
output_gfm
=
html_to_gfm
(
html
)
...
...
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