-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
use NotificationChannels\Bluesky\BlueskyClient; | ||
use NotificationChannels\Bluesky\SessionManager; | ||
use NotificationChannels\Bluesky\Tests\Factories\BlueskyClientResponseFactory; | ||
|
||
test('`getIdentity` generates an identity when none exist', function () { | ||
BlueskyClientResponseFactory::fake([ | ||
BlueskyClient::CREATE_SESSION_ENDPOINT => ['handle' => 'owo'], | ||
BlueskyClient::REFRESH_SESSION_ENDPOINT => ['handle' => 'uwu'], | ||
]); | ||
|
||
/** @var SessionManager */ | ||
$session = resolve(SessionManager::class); | ||
$identity = $session->getIdentity(); | ||
|
||
expect($identity)->handle->toBe('uwu'); | ||
}); | ||
|
||
// Note: this is the same test as above, but the test above | ||
// will need to be changed if/when we decide not to refresh | ||
// sessions if they are not close to their expiration date | ||
test('`getIdentity` refreshes the session automatically', function () { | ||
BlueskyClientResponseFactory::fake([ | ||
BlueskyClient::CREATE_SESSION_ENDPOINT => ['handle' => 'owo'], | ||
BlueskyClient::REFRESH_SESSION_ENDPOINT => ['handle' => 'uwu'], | ||
]); | ||
|
||
/** @var SessionManager */ | ||
$session = resolve(SessionManager::class); | ||
$identity = $session->getIdentity(); | ||
|
||
expect($identity)->handle->toBe('uwu'); | ||
}); |