Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomano committed May 19, 2024
1 parent d37c3a1 commit 257d9c9
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 142 deletions.
49 changes: 0 additions & 49 deletions tests/AbstractIconTest.php

This file was deleted.

24 changes: 0 additions & 24 deletions tests/BrandIconTest.php

This file was deleted.

21 changes: 0 additions & 21 deletions tests/CollectionTest.php

This file was deleted.

63 changes: 63 additions & 0 deletions tests/IconBuilderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php declare(strict_types=1);

use Bugo\FontAwesomeHelper\Enums\Icon;
use Bugo\FontAwesomeHelper\IconBuilder;

beforeEach(function () {
$this->builderV5 = new IconBuilder(Icon::V5->solid('calendar'));
$this->builderV6 = new IconBuilder(Icon::V6->regular('user'));
});

test('text method', function () {
expect($this->builderV6->text())->toBe('fa-regular fa-user')
->and($this->builderV5->text())->toBe('fas fa-calendar');
});

test('html method', function () {
expect($this->builderV6->html())
->toBe('<i class="fa-regular fa-user"></i>');
});

test('addClass method', function () {
expect($this->builderV5->addClass('fa-spin')->text())
->toBe('fas fa-calendar fa-spin');
});

describe('color method', function () {
test('tailwind classes', function () {
expect($this->builderV5->color('text-red-500')->html())
->toBe('<i class="fas fa-calendar text-red-500"></i>');
});

test('common styles', function () {
expect($this->builderV5->color('#000')->html())
->toBe('<i class="fas fa-calendar" style="color:#000"></i>');
});
});

describe('size method', function () {
test('correct size', function () {
expect($this->builderV5->size('lg')->text())
->toBe('fas fa-calendar fa-lg');
});

test('incorrect size', function () {
expect(fn() => $this->builderV5->size('10px')->text())
->toThrow(InvalidArgumentException::class, 'Invalid size: 10px');
});
});

test('title method', function () {
expect($this->builderV5->title('Calendar')->html())
->toBe('<i class="fas fa-calendar" title="Calendar"></i>');
});

test('fixedWidth method', function () {
expect($this->builderV5->fixedWidth()->text())
->toBe('fas fa-calendar fa-fw');
});

test('ariaHidden method', function () {
expect($this->builderV5->ariaHidden()->html())
->toBe('<i class="fas fa-calendar" aria-hidden="true"></i>');
});
33 changes: 33 additions & 0 deletions tests/IconTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php declare(strict_types=1);

use Bugo\FontAwesomeHelper\Enums\Icon;

test('brand method', function () {
expect(Icon::V5->brand('42-group'))->toBe('fab fa-42-group')
->and(Icon::V6->brand('windows'))->toBe('fa-brands fa-windows');
});

test('regular method', function () {
expect(Icon::V5->regular('user'))->toBe('far fa-user')
->and(Icon::V6->regular('clock'))->toBe('fa-regular fa-clock');
});

test('solid method', function () {
expect(Icon::V5->solid('user'))->toBe('fas fa-user')
->and(Icon::V6->solid('folder'))->toBe('fa-solid fa-folder');
});

test('unkhown icon', function () {
expect(Icon::V5->brand('foo'))->toBe('')
->and(Icon::V6->brand('bar'))->toBe('');
});

test('collection method', function () {
expect(Icon::V5->collection())->toBeArray()
->and(Icon::V6->collection())->toContain('fa-solid fa-user');
});

test('random method', function () {
expect(Icon::V5->random())->toBeString()
->and(Icon::V6->random())->not->toBe(Icon::V6->random());
});
24 changes: 0 additions & 24 deletions tests/RegularIconTest.php

This file was deleted.

24 changes: 0 additions & 24 deletions tests/SolidIconTest.php

This file was deleted.

0 comments on commit 257d9c9

Please sign in to comment.