AssetsHelpersTest.php
4.85 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
use Roots\Acorn\Assets\Contracts\Manifest as ManifestContract;
use Roots\Acorn\Tests\Test\TestCase;
use function Spatie\Snapshots\assertMatchesSnapshot;
use function Roots\asset;
use function Roots\bundle;
uses(TestCase::class);
it('asset() can access the default manifest', function () {
$app = new \Roots\Acorn\Application();
$app->singleton('config', fn () => new \Illuminate\Config\Repository([
'assets' => [
'default' => 'app',
'manifests' => [
'app' => [
'path' => $this->fixture('bud_single_runtime/public/app'),
'url' => 'https://k.jo/app',
'assets' => $this->fixture('bud_multi_compiler/public/app/manifest.json'),
'bundles' => $this->fixture('bud_multi_compiler/public/app/entrypoints.json'),
],
'editor' => [
'path' => $this->fixture('bud_single_runtime/public/editor'),
'url' => 'https://k.jo/editor',
'assets' => $this->fixture('bud_multi_compiler/public/editor/manifest.json'),
'bundles' => $this->fixture('bud_multi_compiler/public/editor/entrypoints.json'),
],
]
]
]));
$app->register(\Roots\Acorn\Assets\AssetsServiceProvider::class);
assertMatchesSnapshot(asset('app.js')->uri());
});
it('asset() can access a specified manifest', function () {
$app = new \Roots\Acorn\Application();
$app->singleton('config', fn () => new \Illuminate\Config\Repository([
'assets' => [
'default' => 'app',
'manifests' => [
'app' => [
'path' => $this->fixture('bud_single_runtime/public/app'),
'url' => 'https://k.jo/app',
'assets' => $this->fixture('bud_multi_compiler/public/app/manifest.json'),
'bundles' => $this->fixture('bud_multi_compiler/public/app/entrypoints.json'),
],
'editor' => [
'path' => $this->fixture('bud_single_runtime/public/editor'),
'url' => 'https://k.jo/editor',
'assets' => $this->fixture('bud_multi_compiler/public/editor/manifest.json'),
'bundles' => $this->fixture('bud_multi_compiler/public/editor/entrypoints.json'),
],
]
]
]));
$app->register(\Roots\Acorn\Assets\AssetsServiceProvider::class);
assertMatchesSnapshot(asset('editor.js', 'editor')->uri());
});
it('bundle() can access the default manifest', function () {
$app = new \Roots\Acorn\Application();
$app->singleton('config', fn () => new \Illuminate\Config\Repository([
'assets' => [
'default' => 'app',
'manifests' => [
'app' => [
'path' => $this->fixture('bud_single_runtime/public/app'),
'url' => 'https://k.jo/app',
'assets' => $this->fixture('bud_multi_compiler/public/app/manifest.json'),
'bundles' => $this->fixture('bud_multi_compiler/public/app/entrypoints.json'),
],
'editor' => [
'path' => $this->fixture('bud_single_runtime/public/editor'),
'url' => 'https://k.jo/editor',
'assets' => $this->fixture('bud_multi_compiler/public/editor/manifest.json'),
'bundles' => $this->fixture('bud_multi_compiler/public/editor/entrypoints.json'),
],
]
]
]));
$app->register(\Roots\Acorn\Assets\AssetsServiceProvider::class);
assertMatchesSnapshot(bundle('app')->js()->toJson());
});
it('bundle() can access a specified manifest', function () {
$app = new \Roots\Acorn\Application();
$app->singleton('config', fn () => new \Illuminate\Config\Repository([
'assets' => [
'default' => 'app',
'manifests' => [
'app' => [
'path' => $this->fixture('bud_single_runtime/public/app'),
'url' => 'https://k.jo/app',
'assets' => $this->fixture('bud_multi_compiler/public/app/manifest.json'),
'bundles' => $this->fixture('bud_multi_compiler/public/app/entrypoints.json'),
],
'editor' => [
'path' => $this->fixture('bud_single_runtime/public/editor'),
'url' => 'https://k.jo/editor',
'assets' => $this->fixture('bud_multi_compiler/public/editor/manifest.json'),
'bundles' => $this->fixture('bud_multi_compiler/public/editor/entrypoints.json'),
],
]
]
]));
$app->register(\Roots\Acorn\Assets\AssetsServiceProvider::class);
assertMatchesSnapshot(bundle('editor', 'editor')->js()->toJson());
});