#include <catch2/catch_test_macros.hpp>
#include <fmt/core.h>
#include "render.hpp"
#include "panel.hpp"
#include "map.hpp"
#include "worldbuilder.hpp"
#include "config.hpp"
#include "components.hpp"
#include "systems.hpp"
#include "save.hpp"

using namespace ftxui;
using namespace fmt;
using namespace components;
using namespace lighting;
using std::string;

void run_renderer(SFMLRender &renderer, Panel &panel) {
  panel.render();
  renderer.display();
  REQUIRE(renderer.is_open() == true);
  renderer.clear();
  renderer.draw(panel);
}

TEST_CASE("can render a text panel", "[render]") {
  SFMLRender renderer;
  renderer.init_terminal();

  Panel panel(0, 0, 20, 5);

  auto text_box = Renderer([]{
      return hbox({
        hflow(
            vbox(text("I AM TEXT"))
        )});
    });

  panel.set_renderer(text_box);
  run_renderer(renderer, panel);
  renderer.close();
}

TEST_CASE("can render a grid", "[render]") {
  dbc::log("!!!! NEEDS A REWRITE");
}
