--- /dev/null
+# frozen_string_literal: true
+
+require "test_helper"
+require "author"
+
+class AuthorTest < Minitest::Test
+ def test_that_initialization_values_are_reflected_in_the_created_object
+ grouping = "Daniel Defoe"
+ reading_order = "Daniel Defoe"
+ sort_order = "Defoe, Daniel"
+
+ author = Author.new(grouping, reading_order, sort_order)
+
+ assert_equal grouping, author.grouping
+ assert_equal reading_order, author.reading_order
+ assert_equal sort_order, author.sort_order
+ end
+
+ def test_that_sort_order_is_auto_inferred
+ grouping = "DanielDefoe"
+ reading_order = "Daniel Defoe"
+
+ author = Author.new(grouping, reading_order, nil)
+
+ assert_equal "Defoe, Daniel", author.sort_order
+ end
+
+ def test_inspect
+ author = Author.new("DanielDefoe", "Daniel Defoe", "Defoe, Daniel")
+
+ expected = '(Author: grouping="DanielDefoe" reading_order="Daniel Defoe" sort_order="Defoe, Daniel")'
+
+ assert_equal expected, author.inspect
+ assert_equal expected, author.to_s
+ end
+end
assert_equal false, Book.can_handle?("sample.#{extension}")
end
end
+
+ def test_grouping_for_title
+ data = {
+ "A Study in Scarlet" => "A_Study_in_Scarlet",
+ "That'll be the Day" => "That-ll_be_the_Day",
+ "Banzai!" => "Banzai-",
+ "#tweet_cute" => "-tweet_cute",
+ }
+
+ data.each do |input, expected|
+ assert_equal expected, Book.grouping_for_title(input)
+ end
+ end
end