Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
milwad-dev committed Jan 10, 2024
1 parent a55d281 commit decea9c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/Feature/VisitMonitoringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@
assertDatabaseMissing(config('user-monitoring.visit_monitoring.table'), ['page' => url('/')]);
});

// Ajax

test('visit monitoring store ajax requests', function () {
get('/', ['X-Requested-With' => 'XMLHttpRequest']);

// DB Assertions
assertDatabaseCount(config('user-monitoring.visit_monitoring.table'), 1);
assertDatabaseHas(config('user-monitoring.visit_monitoring.table'), ['created_at' => now()]);
});

test('visit monitoring skip store when ajax mode is off for ajax requests', function () {
config()->set('user-monitoring.visit_monitoring.ajax_requests', false);

get('/', ['X-Requested-With' => 'XMLHttpRequest']);

// DB Assertions
assertDatabaseCount(config('user-monitoring.visit_monitoring.table'), 0);
assertDatabaseMissing(config('user-monitoring.visit_monitoring.table'), ['page' => 'http:\/\/localhost']);
});

/**
* Create user.
*
Expand Down

0 comments on commit decea9c

Please sign in to comment.