fix tests

This commit is contained in:
harshjagad20
2022-01-10 19:02:49 +05:30
parent 54f76f7cbe
commit 9eae813c24
11 changed files with 67 additions and 45 deletions

View File

@ -32,9 +32,12 @@ test('get customer estimates', function () {
test('get customer estimate', function () {
$customer = Auth::guard('customer')->user();
$estimate = Estimate::factory()->create();
$estimate = Estimate::factory()->create([
'customer_id' => $customer->id
]);
getJson("/api/{$customer->company->slug}/v1/customer/estimates/{$estimate->id}")->assertOk();
getJson("/api/v1/{$customer->company->slug}/customer/estimates/{$estimate->id}")
->assertOk();
});
test('customer estimate mark as accepted', function () {
@ -43,15 +46,34 @@ test('customer estimate mark as accepted', function () {
$estimate = Estimate::factory()->create([
'estimate_date' => '1988-07-18',
'expiry_date' => '1988-08-18',
'customer_id' => $customer->id
]);
$status = [
'status' => Estimate::STATUS_ACCEPTED,
'status' => Estimate::STATUS_ACCEPTED
];
postJson("api/v1/{$customer->company->slug}/customer/estimate/{$estimate->id}/accept", $status)->assertOk();
$response = postJson("api/v1/{$customer->company->slug}/customer/estimate/{$estimate->id}/status", $status)
->assertOk();
$estimate2 = Estimate::find($estimate->id);
$this->assertEquals($estimate2->status, Estimate::STATUS_ACCEPTED);
$this->assertEquals($response->json()['data']['status'], Estimate::STATUS_ACCEPTED);
});
test('customer estimate mark as rejected', function () {
$customer = Auth::guard('customer')->user();
$estimate = Estimate::factory()->create([
'estimate_date' => '1988-07-18',
'expiry_date' => '1988-08-18',
'customer_id' => $customer->id
]);
$status = [
'status' => Estimate::STATUS_REJECTED
];
$response = postJson("api/v1/{$customer->company->slug}/customer/estimate/{$estimate->id}/status", $status)
->assertOk();
$this->assertEquals($response->json()['data']['status'], Estimate::STATUS_REJECTED);
});

View File

@ -7,7 +7,6 @@ use Crater\Models\Expense;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Auth;
use Laravel\Sanctum\Sanctum;
use function Pest\Laravel\getJson;
beforeEach(function () {
@ -32,14 +31,11 @@ test('get customer expenses', function () {
test('get customer expense', function () {
$customer = Auth::guard('customer')->user();
$expense = Expense::factory()->create();
getJson("/api/v1/{$customer->company->slug}/customer/expenses/{$expense->id}")->assertOk();
$this->assertDatabaseHas('expenses', [
'expense_category_id' => $expense['expense_category_id'],
'amount' => $expense['amount'],
'exchange_rate' => $expense['exchange_rate'],
'notes' => $expense['notes'],
$expense = Expense::factory()->create([
'customer_id' => $customer->id,
'company_id' => $customer->company->id
]);
getJson("/api/v1/{$customer->company->slug}/customer/expenses/{$expense->id}")
->assertOk();
});

View File

@ -31,7 +31,9 @@ test('get customer invoices', function () {
test('get customer invoice', function () {
$customer = Auth::guard('customer')->user();
$invoice = Invoice::factory()->create();
$invoice = Invoice::factory()->create([
'customer_id' => $customer->id
]);
getJson("/api/v1/{$customer->company->slug}/customer/invoices/{$invoice->id}")->assertOk();

View File

@ -31,7 +31,9 @@ test('get customer payments', function () {
test('get customer payment', function () {
$customer = Auth::guard('customer')->user();
$payment = Payment::factory()->create();
$payment = Payment::factory()->create([
'customer_id' => $customer->id
]);
getJson("/api/v1/{$customer->company->slug}/customer/payments/{$payment->id}")->assertOk();
});