RootsBudMiddlewareTest.php
1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
use Roots\Acorn\Assets\Middleware\RootsBudMiddleware;
use Roots\Acorn\Tests\Test\TestCase;
use function Spatie\Snapshots\assertMatchesSnapshot;
uses(TestCase::class);
it('skips url modification if hmr file is absent', function () {
$middleware = new RootsBudMiddleware('http://localhost:3000/');
$config = $middleware->handle([
'path' => $this->fixture('bud_single_runtime/public'),
'url' => 'https://k.jo/public',
]);
assertMatchesSnapshot($config['url']);
});
it('skips url modification if dev origin is invalid', function () {
$middleware = new RootsBudMiddleware('http://this-does-not-match/');
$config = $middleware->handle([
'path' => $this->fixture('bud_single_runtime_hmr/public'),
'url' => 'https://k.jo/public',
]);
assertMatchesSnapshot($config['url']);
});
it('modifies url when hmr file is present with matching dev origin', function () {
$middleware = new RootsBudMiddleware('http://localhost:3000/');
$config = $middleware->handle([
'path' => $this->fixture('bud_single_runtime_hmr/public'),
'url' => 'https://k.jo/public',
]);
assertMatchesSnapshot($config['url']);
});