<?php

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

test('labels table has expected columns', function () {
    expect(Schema::hasTable('labels'))->toBeTrue();
    expect(Schema::hasColumns('labels', ['id', 'name', 'color', 'hidden_at', 'last_imported_at', 'created_at', 'updated_at']))->toBeTrue();
});

test('labels table enforces unique name', function () {
    DB::table('labels')->insert(['name' => 'Vers 1', 'color' => '#FF0080', 'created_at' => now(), 'updated_at' => now()]);

    expect(fn () => DB::table('labels')->insert(['name' => 'Vers 1', 'color' => '#000000', 'created_at' => now(), 'updated_at' => now()]))
        ->toThrow(\Exception::class);
});

test('labels table allows nullable color', function () {
    DB::table('labels')->insert(['name' => 'TestLabel', 'color' => null, 'created_at' => now(), 'updated_at' => now()]);

    expect(DB::table('labels')->where('name', 'TestLabel')->value('color'))->toBeNull();
});
