Skip to content

Commit

Permalink
Add spec for sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
Subash Pradhan committed Oct 25, 2024
1 parent 3113fa4 commit 5979b50
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions spec/nylas/resources/sessions_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

describe Nylas::Sessions do
let(:sessions) { described_class.new(client) }
let(:response) do
[{
"session_id": "session-id-123"
}, "mock_request_id"]
end

describe "#create" do
it "calls the post method with the correct parameters" do
request_body = {
configuration_id: "configuration-123",
time_to_live: 30
}
path = "#{api_uri}/v3/scheduling/sessions"
allow(sessions).to receive(:post)
.with(path: path, request_body: request_body)
.and_return(response)

sessions_response = sessions.create(request_body: request_body)
expect(sessions_response).to eq(response)
end
end

describe "#destroy" do
it "calls the delete method with the correct parameters" do
session_id = "session-123"
path = "#{api_uri}/v3/scheduling/sessions/#{session_id}"
allow(sessions).to receive(:delete)
.with(path: path)
.and_return([true, "mock_request_id"])

sessions_response = sessions.destroy(session_id: session_id)
expect(sessions_response).to eq([true, "mock_request_id"])
end
end
end

0 comments on commit 5979b50

Please sign in to comment.