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
Boxiang Sun
gitlab-ce
Commits
19dc2fb0
Commit
19dc2fb0
authored
Jan 29, 2019
by
Brett Walker
Committed by
Fatih Acet
Jan 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix TaskListToggleService specs
parent
58cd21c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
40 deletions
+81
-40
spec/services/task_list_toggle_service_spec.rb
spec/services/task_list_toggle_service_spec.rb
+81
-40
No files found.
spec/services/task_list_toggle_service_spec.rb
View file @
19dc2fb0
...
@@ -4,6 +4,7 @@ require 'spec_helper'
...
@@ -4,6 +4,7 @@ require 'spec_helper'
describe
TaskListToggleService
do
describe
TaskListToggleService
do
context
'when '
do
context
'when '
do
let
(
:sourcepos
)
{
true
}
let
(
:markdown
)
do
let
(
:markdown
)
do
<<-
EOT
.
strip_heredoc
<<-
EOT
.
strip_heredoc
* [ ] Task 1
* [ ] Task 1
...
@@ -18,20 +19,20 @@ describe TaskListToggleService do
...
@@ -18,20 +19,20 @@ describe TaskListToggleService do
let
(
:markdown_html
)
do
let
(
:markdown_html
)
do
<<-
EOT
.
strip_heredoc
<<-
EOT
.
strip_heredoc
<ul class="task-list" dir="auto">
<ul
data-sourcepos="1:1-3:0"
class="task-list" dir="auto">
<li class="task-list-item">
<li
data-sourcepos="1:1-1:12"
class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Task 1
<input type="checkbox" class="task-list-item-checkbox" disabled> Task 1
</li>
</li>
<li class="task-list-item">
<li
data-sourcepos="2:1-3:0"
class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled checked> Task 2
<input type="checkbox" class="task-list-item-checkbox" disabled checked> Task 2
</li>
</li>
</ul>
</ul>
<p dir="auto">A paragraph</p>
<p d
ata-sourcepos="4:1-4:11" d
ir="auto">A paragraph</p>
<ol class="task-list" dir="auto">
<ol
data-sourcepos="6:1-7:19"
class="task-list" dir="auto">
<li class="task-list-item">
<li
data-sourcepos="6:1-7:19"
class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled checked> Item 1
<input type="checkbox" class="task-list-item-checkbox" disabled checked> Item 1
<ul class="task-list">
<ul
data-sourcepos="7:4-7:19"
class="task-list">
<li class="task-list-item">
<li
data-sourcepos="7:4-7:19"
class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Sub-item 1
<input type="checkbox" class="task-list-item-checkbox" disabled> Sub-item 1
</li>
</li>
</ul>
</ul>
...
@@ -40,48 +41,88 @@ describe TaskListToggleService do
...
@@ -40,48 +41,88 @@ describe TaskListToggleService do
EOT
EOT
end
end
it
'checks Task 1'
do
shared_examples
'task lists'
do
toggler
=
described_class
.
new
(
markdown
,
markdown_html
,
it
'checks Task 1'
do
index:
1
,
currently_checked:
false
,
toggler
=
described_class
.
new
(
markdown
,
markdown_html
,
line_source:
'* [ ] Task 1'
,
line_number:
1
)
index:
1
,
toggle_as_checked:
true
,
line_source:
'* [ ] Task 1'
,
line_number:
1
,
sourcepos:
sourcepos
)
expect
(
toggler
.
execute
).
to
be_truthy
expect
(
toggler
.
execute
).
to
be_truthy
expect
(
toggler
.
updated_markdown
.
lines
[
0
]).
to
eq
"* [x] Task 1
\n
"
expect
(
toggler
.
updated_markdown
.
lines
[
0
]).
to
eq
"* [x] Task 1
\n
"
expect
(
toggler
.
updated_markdown_html
).
to
include
(
'disabled checked> Task 1'
)
expect
(
toggler
.
updated_markdown_html
).
to
include
(
'disabled checked> Task 1'
)
end
end
it
'unchecks Item 1'
do
it
'unchecks Item 1'
do
toggler
=
described_class
.
new
(
markdown
,
markdown_html
,
toggler
=
described_class
.
new
(
markdown
,
markdown_html
,
index:
3
,
currently_checked:
true
,
index:
3
,
toggle_as_checked:
false
,
line_source:
'1. [X] Item 1'
,
line_number:
6
)
line_source:
'1. [X] Item 1'
,
line_number:
6
,
sourcepos:
sourcepos
)
expect
(
toggler
.
execute
).
to
be_truthy
expect
(
toggler
.
execute
).
to
be_truthy
expect
(
toggler
.
updated_markdown
.
lines
[
5
]).
to
eq
"1. [ ] Item 1
\n
"
expect
(
toggler
.
updated_markdown
.
lines
[
5
]).
to
eq
"1. [ ] Item 1
\n
"
expect
(
toggler
.
updated_markdown_html
).
to
include
(
'disabled> Item 1'
)
expect
(
toggler
.
updated_markdown_html
).
to
include
(
'disabled> Item 1'
)
end
end
it
'returns false if line_source does not match the text'
do
it
'returns false if line_source does not match the text'
do
toggler
=
described_class
.
new
(
markdown
,
markdown_html
,
toggler
=
described_class
.
new
(
markdown
,
markdown_html
,
index:
2
,
currently_checked:
true
,
index:
2
,
toggle_as_checked:
false
,
line_source:
'* [x] Task Added'
,
line_number:
2
)
line_source:
'* [x] Task Added'
,
line_number:
2
,
sourcepos:
sourcepos
)
expect
(
toggler
.
execute
).
to
be_falsey
expect
(
toggler
.
execute
).
to
be_falsey
end
end
it
'returns false if markdown is nil'
do
toggler
=
described_class
.
new
(
nil
,
markdown_html
,
index:
2
,
toggle_as_checked:
false
,
line_source:
'* [x] Task Added'
,
line_number:
2
,
sourcepos:
sourcepos
)
expect
(
toggler
.
execute
).
to
be_falsey
end
it
'returns false if markdown is nil'
do
it
'returns false if markdown_html is nil'
do
toggler
=
described_class
.
new
(
nil
,
markdown_html
,
toggler
=
described_class
.
new
(
markdown
,
nil
,
index:
2
,
currently_checked:
true
,
index:
2
,
toggle_as_checked:
false
,
line_source:
'* [x] Task Added'
,
line_number:
2
)
line_source:
'* [x] Task Added'
,
line_number:
2
,
sourcepos:
sourcepos
)
expect
(
toggler
.
execute
).
to
be_falsey
expect
(
toggler
.
execute
).
to
be_falsey
end
end
end
it
'returns false if markdown_html is nil'
do
context
'when using sourcepos'
do
toggler
=
described_class
.
new
(
markdown
,
nil
,
it_behaves_like
'task lists'
index:
2
,
currently_checked:
true
,
end
line_source:
'* [x] Task Added'
,
line_number:
2
)
context
'when using checkbox indexing'
do
let
(
:sourcepos
)
{
false
}
let
(
:markdown_html
)
do
<<-
EOT
.
strip_heredoc
<ul class="task-list" dir="auto">
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Task 1
</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled checked> Task 2
</li>
</ul>
<p dir="auto">A paragraph</p>
<ol class="task-list" dir="auto">
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled checked> Item 1
<ul class="task-list">
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Sub-item 1
</li>
</ul>
</li>
</ol>
EOT
end
expect
(
toggler
.
execute
).
to
be_falsey
it_behaves_like
'task lists'
end
end
end
end
end
end
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