<?php

use Illuminate\Support\Facades\Mail;

test('otp send requires email', function () {
    $this->postJson('/api/v1/otp/send', [])
        ->assertStatus(422);
});

test('otp send accepts valid email and queues mail', function () {
    Mail::fake();

    $this->postJson('/api/v1/otp/send', ['email' => 'test@example.com'])
        ->assertOk()
        ->assertJsonPath('status', 'success');
});

test('otp verify rejects invalid code', function () {
    $this->postJson('/api/v1/otp/verify', [
        'email' => 'test@example.com',
        'code' => '000000',
    ])->assertStatus(422)
        ->assertJsonPath('status', 'error');
});

test('otp verify requires 6-digit code', function () {
    $this->postJson('/api/v1/otp/verify', [
        'email' => 'test@example.com',
        'code' => '123',
    ])->assertStatus(422);
});
