-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use LF instead CRLF * Simplify list_tag method and memorize the result * Use ordered_list instead of use_ordered_list * ordered_list instead of use_ordered_list * Place ordered_list after toc_levels * Simplify list_tag
- Loading branch information
Showing
5 changed files
with
91 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,76 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class TestOrderedList < Minitest::Test | ||
include TestHelpers | ||
|
||
def test_default_configuration | ||
configuration = Jekyll::TableOfContents::Configuration.new({}) | ||
|
||
assert_equal configuration.use_ordered_list, false | ||
end | ||
|
||
def test_disabled_ordered_list | ||
configuration = Jekyll::TableOfContents::Configuration.new('use_ordered_list' => false) | ||
|
||
assert_equal configuration.use_ordered_list, false | ||
end | ||
|
||
def test_enabled_ordered_list | ||
configuration = Jekyll::TableOfContents::Configuration.new('use_ordered_list' => true) | ||
|
||
assert_equal configuration.use_ordered_list, true | ||
end | ||
|
||
def test_basic_ordered_list_top_heading | ||
parse_with_ordered_list | ||
html = @parser.toc | ||
|
||
assert_match(/^<ol class="section-nav">/, html) | ||
end | ||
|
||
def test_ordered_list_sub_headings | ||
parse_with_ordered_list | ||
html = @parser.toc | ||
|
||
assert_match(/<ol>\n<li class="toc-entry/, html) | ||
end | ||
|
||
def test_ordered_list_top_heading_with_classes | ||
parse_with_ordered_list_and_classes | ||
html = @parser.toc | ||
|
||
assert_match(/^<ol class="top-list-class">/, html) | ||
end | ||
|
||
def test_ordered_list_sub_headings_with_classes | ||
parse_with_ordered_list_and_classes | ||
html = @parser.toc | ||
|
||
assert_match(/<ol class="sublist-class">/, html) | ||
end | ||
|
||
def test_ordered_list_subheadings_with_classes_nested_structure | ||
parse_with_ordered_list_and_classes | ||
html = @parser.toc | ||
|
||
occurrences = html.scan(/<ol class="sublist-class">/).count | ||
|
||
assert_equal occurrences, 5 | ||
end | ||
private | ||
|
||
def parse_with_ordered_list | ||
read_html_and_create_parser('use_ordered_list' => true) | ||
end | ||
|
||
def parse_with_ordered_list_and_classes | ||
read_html_and_create_parser( | ||
'use_ordered_list' => true, | ||
'list_class' => 'top-list-class', | ||
'sublist_class' => 'sublist-class' | ||
) | ||
end | ||
end | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class TestOrderedList < Minitest::Test | ||
include TestHelpers | ||
|
||
def test_default_configuration | ||
configuration = Jekyll::TableOfContents::Configuration.new({}) | ||
|
||
assert_equal configuration.ordered_list, false | ||
end | ||
|
||
def test_disabled_ordered_list | ||
configuration = Jekyll::TableOfContents::Configuration.new('ordered_list' => false) | ||
|
||
assert_equal configuration.ordered_list, false | ||
end | ||
|
||
def test_enabled_ordered_list | ||
configuration = Jekyll::TableOfContents::Configuration.new('ordered_list' => true) | ||
|
||
assert_equal configuration.ordered_list, true | ||
end | ||
|
||
def test_basic_ordered_list_top_heading | ||
parse_with_ordered_list | ||
html = @parser.toc | ||
|
||
assert_match(/^<ol class="section-nav">/, html) | ||
end | ||
|
||
def test_ordered_list_sub_headings | ||
parse_with_ordered_list | ||
html = @parser.toc | ||
|
||
assert_match(/<ol>\n<li class="toc-entry/, html) | ||
end | ||
|
||
def test_ordered_list_top_heading_with_classes | ||
parse_with_ordered_list_and_classes | ||
html = @parser.toc | ||
|
||
assert_match(/^<ol class="top-list-class">/, html) | ||
end | ||
|
||
def test_ordered_list_sub_headings_with_classes | ||
parse_with_ordered_list_and_classes | ||
html = @parser.toc | ||
|
||
assert_match(/<ol class="sublist-class">/, html) | ||
end | ||
|
||
def test_ordered_list_subheadings_with_classes_nested_structure | ||
parse_with_ordered_list_and_classes | ||
html = @parser.toc | ||
|
||
occurrences = html.scan(/<ol class="sublist-class">/).count | ||
|
||
assert_equal occurrences, 5 | ||
end | ||
|
||
private | ||
|
||
def parse_with_ordered_list | ||
read_html_and_create_parser('ordered_list' => true) | ||
end | ||
|
||
def parse_with_ordered_list_and_classes | ||
read_html_and_create_parser( | ||
'ordered_list' => true, | ||
'list_class' => 'top-list-class', | ||
'sublist_class' => 'sublist-class' | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters