use rusty_v8 as v8;
pub fn register_testing_api(_scope: &mut v8::PinScope, _global: v8::Local<v8::Object>) {
if cfg!(feature = "verbose_logging") {
eprintln!("✅ Registered testing API in V8 context");
}
}
#[allow(dead_code)]
fn test_callback(
scope: &mut v8::PinScope,
args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
let name: _ = args.get(0).to_rust_string_lossy(scope);
let function: _ = args.get(1);
if !function.is_function() {
let error: _ =
v8::String::new(scope, "test() requires a function as second argument").unwrap();
let exception: _ = v8::Exception::error(scope, error);
scope.throw_exception(exception);
return;
}
let _func: _ = v8::Local::<v8::Function>::try_from(args.get(1)).unwrap();
if cfg!(feature = "verbose_logging") {
eprintln!("📝 Registered test: {}", name);
}
retval.set(v8::undefined(scope).into());
}
#[allow(dead_code)]
fn describe_callback(
scope: &mut v8::PinScope,
args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
let _name: _ = args.get(0).to_rust_string_lossy(scope);
retval.set(v8::undefined(scope).into());
}
#[allow(dead_code)]
fn it_callback(
scope: &mut v8::PinScope,
args: v8::FunctionCallbackArguments,
retval: v8::ReturnValue,
) {
test_callback(scope, args, retval);
}
#[allow(dead_code)]
fn expect_callback(
scope: &mut v8::PinScope,
args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
let _value: _ = args.get(0);
let expect_obj: _ = v8::Object::new(scope);
retval.set(expect_obj.into());
}
#[allow(dead_code)]
fn before_each_callback(
scope: &mut v8::PinScope,
_args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
if cfg!(feature = "verbose_logging") {
eprintln!("🔧 Registered beforeEach hook");
}
retval.set(v8::undefined(scope).into());
}
#[allow(dead_code)]
fn after_each_callback(
scope: &mut v8::PinScope,
_args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
if cfg!(feature = "verbose_logging") {
eprintln!("🔧 Registered afterEach hook");
}
retval.set(v8::undefined(scope).into());
}
#[allow(dead_code)]
fn before_all_callback(
scope: &mut v8::PinScope,
_args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
if cfg!(feature = "verbose_logging") {
eprintln!("🔧 Registered beforeAll hook");
}
retval.set(v8::undefined(scope).into());
}
#[allow(dead_code)]
fn after_all_callback(
scope: &mut v8::PinScope,
_args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
if cfg!(feature = "verbose_logging") {
eprintln!("🔧 Registered afterAll hook");
}
retval.set(v8::undefined(scope).into());
}
#[allow(dead_code)]
fn skip_callback(
scope: &mut v8::PinScope,
_args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
retval.set(v8::undefined(scope).into());
}
#[allow(dead_code)]
fn only_callback(
scope: &mut v8::PinScope,
_args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
retval.set(v8::undefined(scope).into());
}
#[allow(dead_code)]
fn to_be_matcher(
scope: &mut v8::PinScope,
args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
let _expected: _ = args.get(0);
retval.set(v8::Boolean::new(scope, true).into());
}
#[allow(dead_code)]
fn to_equal_matcher(
scope: &mut v8::PinScope,
args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
let _expected: _ = args.get(0);
retval.set(v8::Boolean::new(scope, true).into());
}
#[allow(dead_code)]
fn to_be_truthy_matcher(
scope: &mut v8::PinScope,
_args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
retval.set(v8::Boolean::new(scope, true).into());
}
#[allow(dead_code)]
fn to_be_falsy_matcher(
scope: &mut v8::PinScope,
_args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
retval.set(v8::Boolean::new(scope, true).into());
}
#[allow(dead_code)]
fn to_contain_matcher(
scope: &mut v8::PinScope,
_args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
retval.set(v8::Boolean::new(scope, true).into());
}