Skip to content

Commit 4fbe4d2

Browse files
RhysLeesgithub-actions[bot]
authored andcommitted
Fix styling
1 parent f77e485 commit 4fbe4d2

File tree

2 files changed

+59
-61
lines changed

2 files changed

+59
-61
lines changed

tests/JsonEntryFieldTest.php

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
<?php
22

33
use CodebarAg\FilamentJsonField\Infolists\Components\JsonEntry;
4-
use Filament\Infolists\Infolist;
54
use Filament\Infolists\Concerns\InteractsWithInfolists;
5+
use Filament\Infolists\Infolist;
66
use Livewire\Component;
7-
use Livewire\Livewire;
87

98
// Test component for infolist integration
109
class TestJsonEntryComponent extends Component
1110
{
1211
use InteractsWithInfolists;
1312

1413
public array $data = [
15-
'json_field' => ['key' => 'value', 'nested' => ['test' => 'data']]
14+
'json_field' => ['key' => 'value', 'nested' => ['test' => 'data']],
1615
];
1716

1817
public function mount(): void
@@ -37,11 +36,11 @@ public function render()
3736
}
3837

3938
// Create a simple test view for infolists
40-
if (!file_exists(__DIR__ . '/../resources/views/livewire/')) {
41-
mkdir(__DIR__ . '/../resources/views/livewire/', 0755, true);
39+
if (! file_exists(__DIR__.'/../resources/views/livewire/')) {
40+
mkdir(__DIR__.'/../resources/views/livewire/', 0755, true);
4241
}
4342

44-
file_put_contents(__DIR__ . '/../resources/views/livewire/test-infolist-component.blade.php', '
43+
file_put_contents(__DIR__.'/../resources/views/livewire/test-infolist-component.blade.php', '
4544
<div>
4645
{{ $this->infolist }}
4746
</div>
@@ -50,14 +49,14 @@ public function render()
5049
describe('JsonEntry Component', function () {
5150
it('can be instantiated', function () {
5251
$entry = JsonEntry::make('json_field');
53-
52+
5453
expect($entry)->toBeInstanceOf(JsonEntry::class);
5554
expect($entry->getName())->toBe('json_field');
5655
});
5756

5857
it('has correct default values', function () {
5958
$entry = JsonEntry::make('json_field');
60-
59+
6160
expect($entry->getHasLineNumbers())->toBe(true);
6261
expect($entry->getHasLineWrapping())->toBe(true);
6362
expect($entry->getHasAutoCloseBrackets())->toBe(true);
@@ -146,7 +145,7 @@ public function render()
146145
->autoCloseBrackets(true)
147146
->foldingCode(true)
148147
->foldedCode(true);
149-
148+
150149
expect($entry->getHasDarkTheme())->toBe(true);
151150
expect($entry->getHasLineNumbers())->toBe(true);
152151
expect($entry->getHasLineWrapping())->toBe(true);
@@ -157,37 +156,37 @@ public function render()
157156

158157
it('can have a label', function () {
159158
$entry = JsonEntry::make('json_field')->label('JSON Data');
160-
159+
161160
expect($entry->getLabel())->toBe('JSON Data');
162161
});
163162

164163
it('can have a name', function () {
165164
$entry = JsonEntry::make('json_field')->name('custom_name');
166-
165+
167166
expect($entry->getName())->toBe('custom_name');
168167
});
169168

170169
it('can have an ID', function () {
171170
$entry = JsonEntry::make('json_field')->id('custom_id');
172-
171+
173172
expect($entry->getId())->toBe('custom_id');
174173
});
175174

176175
it('can be hidden', function () {
177176
$entry = JsonEntry::make('json_field')->hidden();
178-
177+
179178
expect($entry->isHidden())->toBe(true);
180179
});
181180

182181
it('can be visible', function () {
183182
$entry = JsonEntry::make('json_field')->visible();
184-
183+
185184
expect($entry->isHidden())->toBe(false);
186185
});
187186

188187
it('can have a hint', function () {
189188
$entry = JsonEntry::make('json_field')->hint('JSON data display');
190-
189+
191190
expect($entry->getHint())->toBe('JSON data display');
192191
});
193192

@@ -201,7 +200,7 @@ public function render()
201200
->autoCloseBrackets(true)
202201
->foldingCode(true)
203202
->foldedCode(true);
204-
203+
205204
expect($entry->getLabel())->toBe('JSON Data');
206205
expect($entry->getHint())->toBe('JSON data display');
207206
expect($entry->getHasDarkTheme())->toBe(true);
@@ -214,24 +213,24 @@ public function render()
214213

215214
it('can format JSON data correctly', function () {
216215
$entry = JsonEntry::make('json_field');
217-
216+
218217
$testData = ['key' => 'value', 'nested' => ['test' => 'data']];
219218
$entry->state($testData);
220-
219+
221220
expect($entry->getState())->toBe($testData);
222221
});
223222

224223
it('can handle null values', function () {
225224
$entry = JsonEntry::make('json_field');
226-
225+
227226
$entry->state(null);
228-
227+
229228
expect($entry->getState())->toBeNull();
230229
});
231230

232231
it('can handle complex nested JSON', function () {
233232
$entry = JsonEntry::make('json_field');
234-
233+
235234
$complexData = [
236235
'users' => [
237236
[
@@ -243,41 +242,41 @@ public function render()
243242
'notifications' => true,
244243
'preferences' => [
245244
'language' => 'en',
246-
'timezone' => 'UTC'
247-
]
248-
]
245+
'timezone' => 'UTC',
246+
],
247+
],
249248
],
250249
[
251250
'id' => 2,
252251
'name' => 'Jane Smith',
253252
'email' => '[email protected]',
254253
'settings' => [
255254
'theme' => 'light',
256-
'notifications' => false
257-
]
258-
]
255+
'notifications' => false,
256+
],
257+
],
259258
],
260259
'metadata' => [
261260
'total_users' => 2,
262261
'created_at' => '2024-01-01T00:00:00Z',
263-
'tags' => ['important', 'urgent', 'feature']
264-
]
262+
'tags' => ['important', 'urgent', 'feature'],
263+
],
265264
];
266-
265+
267266
$entry->state($complexData);
268-
267+
269268
expect($entry->getState())->toBe($complexData);
270269
});
271270

272271
it('has correct view path', function () {
273272
$entry = JsonEntry::make('json_field');
274-
273+
275274
expect($entry->getView())->toBe('filament-json-field::infolists.components.json-entry');
276275
});
277276

278277
it('can have extra attributes', function () {
279278
$entry = JsonEntry::make('json_field')->extraAttributes(['data-test' => 'value']);
280-
279+
281280
expect($entry->getExtraAttributes())->toBe(['data-test' => 'value']);
282281
});
283282
});

tests/JsonInputFieldTest.php

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?php
22

33
use CodebarAg\FilamentJsonField\Forms\Components\JsonInput;
4-
use Filament\Forms\Form;
54
use Filament\Forms\Concerns\InteractsWithForms;
5+
use Filament\Forms\Form;
66
use Livewire\Component;
7-
use Livewire\Livewire;
87

98
// Test component for form integration
109
class TestJsonInputComponent extends Component
@@ -36,11 +35,11 @@ public function render()
3635
}
3736

3837
// Create a simple test view
39-
if (!file_exists(__DIR__ . '/../resources/views/livewire/')) {
40-
mkdir(__DIR__ . '/../resources/views/livewire/', 0755, true);
38+
if (! file_exists(__DIR__.'/../resources/views/livewire/')) {
39+
mkdir(__DIR__.'/../resources/views/livewire/', 0755, true);
4140
}
4241

43-
file_put_contents(__DIR__ . '/../resources/views/livewire/test-component.blade.php', '
42+
file_put_contents(__DIR__.'/../resources/views/livewire/test-component.blade.php', '
4443
<div>
4544
{{ $this->form }}
4645
</div>
@@ -49,14 +48,14 @@ public function render()
4948
describe('JsonInput Component', function () {
5049
it('can be instantiated', function () {
5150
$field = JsonInput::make('json_field');
52-
51+
5352
expect($field)->toBeInstanceOf(JsonInput::class);
5453
expect($field->getName())->toBe('json_field');
5554
});
5655

5756
it('has correct default values', function () {
5857
$field = JsonInput::make('json_field');
59-
58+
6059
expect($field->getHasLineNumbers())->toBe(true);
6160
expect($field->getHasLineWrapping())->toBe(true);
6261
expect($field->getHasAutoCloseBrackets())->toBe(true);
@@ -139,17 +138,17 @@ public function render()
139138

140139
it('has correct validation rules', function () {
141140
$field = JsonInput::make('json_field');
142-
141+
143142
$rules = $field->getValidationRules();
144-
143+
145144
expect($rules)->toContain('array');
146145
});
147146

148147
it('has correct validation messages', function () {
149148
$field = JsonInput::make('json_field');
150-
149+
151150
$messages = $field->getValidationMessages();
152-
151+
153152
expect($messages)->toHaveKey('array');
154153
expect($messages['array'])->toBe('The :attribute must be valid JSON.');
155154
});
@@ -162,7 +161,7 @@ public function render()
162161
->autoCloseBrackets(true)
163162
->foldingCode(true)
164163
->foldedCode(true);
165-
164+
166165
expect($field->getHasDarkTheme())->toBe(true);
167166
expect($field->getHasLineNumbers())->toBe(true);
168167
expect($field->getHasLineWrapping())->toBe(true);
@@ -173,18 +172,18 @@ public function render()
173172

174173
it('can be made required', function () {
175174
$field = JsonInput::make('json_field')->required();
176-
175+
177176
$rules = $field->getValidationRules();
178-
177+
179178
expect($rules)->toContain('required');
180179
});
181180

182181
it('can have custom validation rules', function () {
183182
$field = JsonInput::make('json_field')
184183
->rules(['array', 'min:1']);
185-
184+
186185
$rules = $field->getValidationRules();
187-
186+
188187
expect($rules)->toContain('array');
189188
expect($rules)->toContain('min:1');
190189
});
@@ -195,58 +194,58 @@ public function render()
195194
'array' => 'Custom array message',
196195
'required' => 'Custom required message',
197196
]);
198-
197+
199198
$messages = $field->getValidationMessages();
200-
199+
201200
expect($messages['array'])->toBe('Custom array message');
202201
expect($messages['required'])->toBe('Custom required message');
203202
});
204203

205204
it('can be made read-only', function () {
206205
$field = JsonInput::make('json_field')->readOnly();
207-
206+
208207
expect($field->isReadOnly())->toBe(true);
209208
});
210209

211210
it('can be disabled', function () {
212211
$field = JsonInput::make('json_field')->disabled();
213-
212+
214213
expect($field->isDisabled())->toBe(true);
215214
});
216215

217216
it('can have a label', function () {
218217
$field = JsonInput::make('json_field')->label('JSON Data');
219-
218+
220219
expect($field->getLabel())->toBe('JSON Data');
221220
});
222221

223222
it('can have a name', function () {
224223
$field = JsonInput::make('json_field')->name('custom_name');
225-
224+
226225
expect($field->getName())->toBe('custom_name');
227226
});
228227

229228
it('can have an ID', function () {
230229
$field = JsonInput::make('json_field')->id('custom_id');
231-
230+
232231
expect($field->getId())->toBe('custom_id');
233232
});
234233

235234
it('can be hidden', function () {
236235
$field = JsonInput::make('json_field')->hidden();
237-
236+
238237
expect($field->isHidden())->toBe(true);
239238
});
240239

241240
it('can be visible', function () {
242241
$field = JsonInput::make('json_field')->visible();
243-
242+
244243
expect($field->isHidden())->toBe(false);
245244
});
246245

247246
it('can have a hint', function () {
248247
$field = JsonInput::make('json_field')->hint('Enter valid JSON');
249-
248+
250249
expect($field->getHint())->toBe('Enter valid JSON');
251250
});
252251

@@ -261,7 +260,7 @@ public function render()
261260
->autoCloseBrackets(true)
262261
->foldingCode(true)
263262
->foldedCode(true);
264-
263+
265264
expect($field->getLabel())->toBe('JSON Data');
266265
expect($field->getHint())->toBe('Enter valid JSON');
267266
expect($field->isRequired())->toBe(true);
@@ -275,7 +274,7 @@ public function render()
275274

276275
it('has correct view path', function () {
277276
$field = JsonInput::make('json_field');
278-
277+
279278
expect($field->getView())->toBe('filament-json-field::forms.components.json-input');
280279
});
281280

0 commit comments

Comments
 (0)