test_that("composing a simple message is possible", { # Create a simple email message with no text email <- compose_email() # Expect an object of class `email_message` and type of 'list' expect_s3_class(email, "email_message") expect_type(email, "list") # Expect the object to be a list of length 3 expect_equal(length(email), 4) # Expect specific names for each of # the list components expect_equal( names(email), c("html_str", "html_html", "attachments", "images") ) # Expect that the first two list components # are of the class `character` expect_type(email$html_str, "character") expect_type(email$html_html, "character") # Expect that the third list component is a `list` expect_type(email$attachments, "list") }) test_that("email components appear in the HTML message", { # Create a simple email message with text in # the body component email <- compose_email(body = "test_text_in_body") # Expect that the test string is available in the HTML expect_true(grepl("test_text_in_body", email$html_str)) # Create a simple email message with text in # the header component email <- compose_email(header = "test_text_in_header") # Expect that the test string is available in the HTML expect_true(grepl("test_text_in_header", email$html_str)) # Create a simple email message with text in # the footer component email <- compose_email(header = "test_text_in_footer") # Expect that the test string is available in the HTML expect_true(grepl("test_text_in_footer", email$html_str)) # Create a simple email message with text in all # three components (header, body, and footer) email <- compose_email( body = "test_text_in_body", header = "test_text_in_header", footer = "test_text_in_footer" ) # Expect that all three strings are available in the HTML expect_true( all( c( grepl("test_text_in_body", email$html_str), grepl("test_text_in_header", email$html_str), grepl("test_text_in_footer", email$html_str) ) ) ) # Create a simple email message with text in # the body component and a title email <- compose_email( body = "test_text_in_body", title = "email_title" ) # Expect that the title string appears within