Both Book::update() methods update the category

This commit is contained in:
Veloman Yunkan
2021-03-15 17:56:15 +04:00
parent a870e05621
commit b7b0bdbdd8
2 changed files with 24 additions and 0 deletions

View File

@ -144,3 +144,25 @@ TEST(BookTest, updateFromXMLCategoryHandlingTest)
EXPECT_EQ(book.getCategory(), "category_attribute_overrides_tags");
}
}
TEST(BookTest, setTagsDoesntAffectCategory)
{
kiwix::Book book;
book.setTags("_category:youtube");
ASSERT_EQ("", book.getCategory());
}
TEST(BookTest, updateCopiesCategory)
{
const XMLDoc xml(R"(<book id="abcd" category="ted"></book>)");
kiwix::Book book;
book.updateFromXml(xml.child("book"), "");
kiwix::Book newBook;
newBook.setId("abcd");
EXPECT_EQ(newBook.getCategory(), "");
newBook.update(book);
EXPECT_EQ(newBook.getCategory(), "ted");
}