

test_that("geom_*side* returns ggside_layer",{
  expect_s3_class(geom_xsidebar(), "ggside_layer")
  expect_s3_class(geom_xsideboxplot(), "ggside_layer")
  expect_s3_class(geom_xsidecol(), "ggside_layer")
  expect_s3_class(geom_xsidedensity(), "ggside_layer")
  expect_s3_class(geom_xsidefreqpoly(), "ggside_layer")
  expect_s3_class(geom_xsidehistogram(), "ggside_layer")
  expect_s3_class(geom_xsideline(), "ggside_layer")
  expect_s3_class(geom_xsidepath(), "ggside_layer")
  expect_s3_class(geom_xsidepoint(), "ggside_layer")
  expect_s3_class(geom_xsidesegment(), "ggside_layer")
  expect_s3_class(geom_xsidetext(), "ggside_layer")
  expect_s3_class(geom_xsidetile(), "ggside_layer")
  expect_s3_class(geom_xsideviolin(), "ggside_layer")
  expect_s3_class(geom_ysidebar(), "ggside_layer")
  expect_s3_class(geom_ysideboxplot(), "ggside_layer")
  expect_s3_class(geom_ysidecol(), "ggside_layer")
  expect_s3_class(geom_ysidedensity(), "ggside_layer")
  expect_s3_class(geom_ysidefreqpoly(), "ggside_layer")
  expect_s3_class(geom_ysidehistogram(), "ggside_layer")
  expect_s3_class(geom_ysideline(), "ggside_layer")
  expect_s3_class(geom_ysidepath(), "ggside_layer")
  expect_s3_class(geom_ysidepoint(), "ggside_layer")
  expect_s3_class(geom_ysidesegment(), "ggside_layer")
  expect_s3_class(geom_ysidetext(), "ggside_layer")
  expect_s3_class(geom_ysidetile(), "ggside_layer")
  expect_s3_class(geom_ysideviolin(), "ggside_layer")
})

test_that("ggside function returns ggside_options",{
  expect_s3_class(ggside(), "ggside_options")
})

p <- ggplot(NULL) + geom_blank()

test_that("adding ggside_layer to ggplot makes ggside object",{
  expect_s3_class(p, "ggplot")
  expect_is_ggside <- function(p, l) {
    p_ <- p + l
    expect_s3_class(p_, "ggside")
  }
  expect_is_ggside(p, ggside())
  expect_is_ggside(p, geom_xsidebar())
  expect_is_ggside(p, geom_xsideboxplot())
  expect_is_ggside(p, geom_xsidecol())
  expect_is_ggside(p, geom_xsidedensity())
  expect_is_ggside(p, geom_xsidefreqpoly())
  expect_is_ggside(p, geom_xsidehistogram())
  expect_is_ggside(p, geom_xsideline())
  expect_is_ggside(p, geom_xsidepath())
  expect_is_ggside(p, geom_xsidepoint())
  expect_is_ggside(p, geom_xsidesegment())
  expect_is_ggside(p, geom_xsidetext())
  expect_is_ggside(p, geom_xsidetile())
  expect_is_ggside(p, geom_xsideviolin())
  expect_is_ggside(p, geom_ysidebar())
  expect_is_ggside(p, geom_ysideboxplot())
  expect_is_ggside(p, geom_ysidecol())
  expect_is_ggside(p, geom_ysidedensity())
  expect_is_ggside(p, geom_ysidefreqpoly())
  expect_is_ggside(p, geom_ysidehistogram())
  expect_is_ggside(p, geom_ysideline())
  expect_is_ggside(p, geom_ysidepath())
  expect_is_ggside(p, geom_ysidepoint())
  expect_is_ggside(p, geom_ysidesegment())
  expect_is_ggside(p, geom_ysidetext())
  expect_is_ggside(p, geom_ysidetile())
  expect_is_ggside(p, geom_ysideviolin())
})

test_that("ggside() class operates correctly", {
  obj <- ggside()
  expect_s3_class(obj, "ggside_options")
  expect_equal(obj$collapse, NULL)
  expect_equal(obj$draw_x_on, NULL)
  expect_equal(obj$draw_y_on, NULL)
  expect_equal(obj$scales, NULL)
  expect_equal(obj$sides_used, NULL)
  expect_equal(obj$respect_side_labels, NULL)
  expect_equal(obj$strip, NULL)
  expect_equal(obj$x.pos, NULL)
  expect_equal(obj$y.pos, NULL)
  expect_equal(obj$xsidey, NULL)
  expect_equal(obj$ysidex, NULL)
  p2 <- p + obj
  obj2 <- p2$ggside
  expect_s3_class(obj2, "ggside_options")
  expect_equal(obj2$collapse, NULL)
  expect_equal(obj2$draw_x_on, "default")
  expect_equal(obj2$draw_y_on, "default")
  expect_equal(obj2$scales, "fixed")
  expect_equal(obj2$sides_used, character())
  expect_equal(obj2$respect_side_labels, "default")
  expect_equal(obj2$strip, "default")
  expect_equal(obj2$x.pos, "top")
  expect_equal(obj2$y.pos, "right")
  expect_equal(obj2$xsidey, NULL)
  expect_equal(obj2$ysidex, NULL)
})

