Skip to content

Instantly share code, notes, and snippets.

@abuiles
Created March 12, 2017 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save abuiles/1134493f99d8c4f2c6368ad8cb4ceacf to your computer and use it in GitHub Desktop.
Save abuiles/1134493f99d8c4f2c6368ad8cb4ceacf to your computer and use it in GitHub Desktop.
require 'test_helper'
class ChapterTest < Minitest::Test
def chapters
[
{
position: 324
},
{
position: 328
},
{
position: 887
},
{
position: 105
},
{
position: 639
}
]
end
def expected
[
{
position: 105,
next: 324,
},
{
position: 324,
next: 328,
previous: 105
},
{
position: 328,
next: 639,
previous: 324
},
{
position: 639,
next: 887,
previous: 328
},
{
position: 887,
previous: 639
}
]
end
def test_that_it_normalizes
assert_equal expected, Kindlemd::Chapter.normalize(chapters)
end
def test_that_it_works_with_empty
assert_equal [], Kindlemd::Chapter.normalize([])
end
def test_that_it_works_with_one_element
assert_equal [{position: 1}], Kindlemd::Chapter.normalize([{position: 1}])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment