tests/testthat/test-logo.R

# Test for logo-related objects.

test_that("'make_logo' function correctly sets the package version", {
    # Create a temporary file.
    path <- tempfile("parabar-logo")

    # Create a mock logo template.
    mock_logo_template <- c("parabar {{major}}.{{minor}}.{{patch}}")

    # Write mock logo template to the temporary file.
    writeLines(mock_logo_template, path)

    # Remove the file on exit.
    on.exit({
        # Remove.
        unlink(path)
    })

    # Expect that the logo is produced with the correct version.
    expect_equal(
        (template = path, version = c(1, 2, 3)),
        c("parabar 1.2.3")
    )

    # Expect that the logo version can also handle character.
    expect_equal(
        (template = path, version = c(1, "x", "x")),
        c("parabar 1.x.x")
    )
})


test_that("'LOGO' constant exists and is of correct type", {
    # Expect that the `LOGO` constant is not null.
    expect_false(is.null())

    # Expect that the `LOGO` constant has the correct type.
    expect_true(is(, "parabar"))
})


test_that("'LOGO' is printed correctly", {
    # Capture the output of the `S3` method.
    output <- capture.output(print())

    # Expect the logo to contain a given package version.
    expect_true(grepl("v\\d\\.x\\.x", output[2], perl = TRUE))
})

Try the parabar package in your browser

Any scripts or data that you put into this service are public.

parabar documentation built on May 29, 2024, 8:42 a.m.