#include <webfront/WebFront.hpp>
#include <webfront/testing/Jasmine.hpp>
#include <stdexcept>
#include <iostream>
#include <string_view>

using App = webfront::EmbeddedWebFront;

int main(int argc, char** argv) {
    if (argc == 2 && std::string_view{argv[1]} == "--version") {
        std::cout << "Quote 1.0\n";
        return 0;
    }
    App app{{.port = "0", .documentRoot = "ui"}};
    app.cppFunction("quote.calculate", [](int count) {
        if (count < 1 || count > 1000)
            throw std::invalid_argument("Invalid quantity");
        return count * 25;
    });
    webfront::testing::JasmineTest tests{app};
    app.show();
    app.shutdown();
    return tests.exitCode();
}
