File: /home/xedaptot/ai.naniguide.com/tests/Feature/AdTemplateFeatureTest.php
<?php
use App\Model\AdTemplate;
test('ad template formats are valid', function () {
expect(AdTemplate::FORMATS)->toBe(['image', 'video', 'carousel', 'story', 'feed']);
});
test('ad template format labels exist for all formats', function () {
foreach (AdTemplate::FORMATS as $format) {
expect(AdTemplate::FORMAT_LABELS)->toHaveKey($format);
}
});
test('ad template fillable fields are correct', function () {
$template = new AdTemplate();
expect($template->getFillable())->toContain('name', 'platform', 'format', 'thumbnail_url', 'content', 'category', 'is_featured', 'use_count');
});
test('ad template casts are correct', function () {
$template = new AdTemplate();
$casts = $template->getCasts();
expect($casts['content'])->toBe('json');
expect($casts['is_featured'])->toBe('boolean');
expect($casts['use_count'])->toBe('integer');
});
test('ad template format label accessor works', function () {
$template = new AdTemplate();
$template->format = 'image';
expect($template->format_label)->toBe('Image Ad');
$template->format = 'video';
expect($template->format_label)->toBe('Video Ad');
});
test('ad template platform label accessor works', function () {
$template = new AdTemplate();
$template->platform = 'meta';
expect($template->platform_label)->toBe('Meta (Facebook/Instagram)');
$template->platform = 'universal';
expect($template->platform_label)->toBe('Universal');
});
test('ad template isSystemTemplate returns true when customer_id null', function () {
$template = new AdTemplate();
$template->customer_id = null;
expect($template->isSystemTemplate())->toBeTrue();
$template->customer_id = 1;
expect($template->isSystemTemplate())->toBeFalse();
});
test('ad template can be created via factory', function () {
$template = AdTemplate::factory()->make();
expect($template->name)->not->toBeEmpty();
expect($template->format)->toBe('image');
});