require 'helper'

describe Bearcat::Client::Conversations do
  before do
    @client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
  end

  context 'POST' do

    it "creates a conversation" do
      body = {recipients: %w(1), body: 'testing'}
      stub_post(@client, "/api/v1/conversations").with(body: body).to_return(json_response("conversation.json"))
      conversation = @client.create_conversation(body)
      message = conversation.first['messages']
      message.count.should == 1
      message.first['body'].should == 'testing'
    end
  end

  context 'DELETE' do

    it "deletes a conversation" do
      stub_delete(@client, "/api/v1/conversations/1").to_return(json_response("deleted_conversation.json"))
      deleted_conversation = @client.delete_conversation("1")
      deleted_conversation["id"].should == 1
      deleted_conversation["message_count"].should == 0
    end
  end

end