BudCompatabilityTest.php
3.03 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
<?php
use Illuminate\Support\Collection;
use Roots\Acorn\Assets\Bundle;
use Roots\Acorn\Tests\Test\TestCase;
use function Spatie\Snapshots\assertMatchesJsonSnapshot;
use function Spatie\Snapshots\assertMatchesSnapshot;
uses(TestCase::class);
beforeEach(fn () => Bundle::resetInlinedSources());
it('supports bud v6: build', function () {
$manifest = json_decode(file_get_contents($this->fixture('bud_v6_single_runtime/public/entrypoints.json')), JSON_OBJECT_AS_ARRAY);
$app = new Bundle('app', $manifest['app'], $this->fixture('bud_v6_single_runtime/public'), 'https://k.jo/public');
$editor = new Bundle('editor', $manifest['editor'], $this->fixture('bud_v6_single_runtime/public'), 'https://k.jo/public');
$this->stub('wp_add_inline_script')
->shouldBeCalled()
->once()
->withAnyArgs();
$this->stub('wp_enqueue_script')
->shouldBeCalled()
->times(4)
->withAnyArgs();
$app->enqueueJs();
$editor->enqueueJs();
});
it('supports bud v6: build --esm', function () {
$manifest = json_decode(file_get_contents($this->fixture('bud_v6_single_runtime_esm/public/entrypoints.json')), JSON_OBJECT_AS_ARRAY);
$app = new Bundle('app', $manifest['app'], $this->fixture('bud_v6_single_runtime_esm/public'), 'https://k.jo/public');
$editor = new Bundle('editor', $manifest['editor'], $this->fixture('bud_v6_single_runtime_esm/public'), 'https://k.jo/public');
$this->stub('wp_add_inline_script')
->shouldBeCalled()
->once()
->withAnyArgs();
$this->stub('wp_enqueue_script')
->shouldBeCalled()
->times(4)
->withAnyArgs();
$app->enqueueJs();
$editor->enqueueJs();
});
it('supports bud v6: dev', function () {
$manifest = json_decode(file_get_contents($this->fixture('bud_v6_single_runtime_hmr/public/entrypoints.json')), JSON_OBJECT_AS_ARRAY);
$app = new Bundle('app', $manifest['app'], $this->fixture('bud_v6_single_runtime_hmr/public'), 'https://k.jo/public');
$editor = new Bundle('editor', $manifest['editor'], $this->fixture('bud_v6_single_runtime_hmr/public'), 'https://k.jo/public');
$this->stub('wp_add_inline_script')
->shouldBeCalled()
->never();
$this->stub('wp_enqueue_script')
->shouldBeCalled()
->times(2)
->withAnyArgs();
$app->enqueueJs();
$editor->enqueueJs();
});
it('supports bud v6: dev --esm', function () {
$manifest = json_decode(file_get_contents($this->fixture('bud_v6_single_runtime_hmr_esm/public/entrypoints.json')), JSON_OBJECT_AS_ARRAY);
$app = new Bundle('app', $manifest['app'], $this->fixture('bud_v6_single_runtime_hmr_esm/public'), 'https://k.jo/public');
$editor = new Bundle('editor', $manifest['editor'], $this->fixture('bud_v6_single_runtime_hmr_esm/public'), 'https://k.jo/public');
$this->stub('wp_add_inline_script')
->shouldBeCalled()
->never();
$this->stub('wp_enqueue_script')
->shouldBeCalled()
->times(2)
->withAnyArgs();
$app->enqueueJs();
$editor->enqueueJs();
});