Skip to content

Commit c6e2516

Browse files
committed
Added typographic rule registration & removal tests
1 parent 2a5de07 commit c6e2516

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/Feature/TypographyTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Whitecube\Strings\ServiceProvider;
4+
use Whitecube\Strings\Typography;
45

56
it('can load ServiceProvider correctly', function() {
67
expect(app()->providerIsLoaded(ServiceProvider::class))->toBeTrue();
@@ -40,3 +41,17 @@
4041
expect((string) str($value)->typography())->toBe($expectation);
4142
}
4243
});
44+
45+
it('can register and remove custom typographic rules', function() {
46+
Typography::rule(
47+
key: 'a-to-b',
48+
regex: '/a/',
49+
callback: fn(array $matches) => 'b',
50+
);
51+
52+
expect((string) str('...Banana !')->typography())->toBe('&hellip;Bbnbnb&nbsp;!');
53+
54+
Typography::remove('a-to-b');
55+
56+
expect((string) str('...Banana !')->typography())->toBe('&hellip;Banana&nbsp;!');
57+
});

0 commit comments

Comments
 (0)