Skip to content

Can explain how to write test for webhook? #507

Answered by fabio-ivona
Taurinz359 asked this question in Q&A
Discussion options

You must be logged in to vote

something like this:

test('can handle start command', function(){
    Telegraph::fake();

    $chat = TelegraphChat::factory()->create();

    post(route('telegraph.webhook', $chat->bot), [
        'message' => [
            'message_id' => 42,
            'date' => now()->timestamp,
            'chat' => [
                'id' => $chat->chat_id,
                'type' => 'private'
            ],
            'text' => '/start',
        ]
    ])->assertStatus(204);

    Telegraph::assertSent('this is start function');

});

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@Taurinz359
Comment options

Comment options

You must be logged in to vote
1 reply
@fabio-ivona
Comment options

Answer selected by Taurinz359
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants