Add Mets for InvoiceResource

This commit is contained in:
Philipp Lang 2023-12-16 22:30:56 +01:00
parent e37d98f168
commit 457d433722
2 changed files with 35 additions and 1 deletions

View File

@ -41,9 +41,26 @@ class InvoiceResource extends JsonResource
return [
'links' => [
'mass-store' => route('invoice.mass-store'),
'store' => route('invoice.store'),
],
'vias' => BillKind::forSelect(),
'statuses' => InvoiceStatus::forSelect(),
'default' => [
'to' => [
'name' => '',
'address' => '',
'zip' => '',
'location' => '',
],
'positions' => [],
'greeting' => '',
'status' => InvoiceStatus::NEW->value,
'via' => null,
],
'default_position' => [
'price' => 0,
'description' => '',
]
];
}
}

View File

@ -33,8 +33,25 @@ class InvoiceIndexActionTest extends TestCase
->assertInertiaPath('data.data.0.status', 'Rechnung gestellt')
->assertInertiaPath('data.data.0.via', 'Post')
->assertInertiaPath('data.meta.links.mass-store', route('invoice.mass-store'))
->assertInertiaPath('data.meta.links.store', route('invoice.store'))
->assertInertiaPath('data.meta.vias.0', ['id' => 'E-Mail', 'name' => 'E-Mail'])
->assertInertiaPath('data.meta.statuses.0', ['id' => 'Neu', 'name' => 'Neu']);
->assertInertiaPath('data.meta.statuses.0', ['id' => 'Neu', 'name' => 'Neu'])
->assertInertiaPath('data.meta.default', [
'to' => [
'name' => '',
'address' => '',
'zip' => '',
'location' => '',
],
'positions' => [],
'greeting' => '',
'status' => InvoiceStatus::NEW->value,
'via' => null,
])
->assertInertiaPath('data.meta.default_position', [
'price' => 0,
'description' => '',
]);
}
public function testValuesCanBeNull(): void