Skip to content

Commit dca830a

Browse files
committed
NO-ISSUE Add test for get followers
1 parent 3d429f8 commit dca830a

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

spec/line/bot/v2/misc_spec.rb

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@
159159

160160
describe 'GET /v2/bot/followers/ids' do
161161
let(:client) { Line::Bot::V2::MessagingApi::ApiClient.new(channel_access_token: 'test-channel-access-token') }
162-
let(:response_body) { { "user_ids" => ["U1234567890", "U0987654321"] }.to_json }
163162
let(:response_code) { 200 }
164163

165164
it 'returns a list of followers successfully without optional parameters' do
165+
response_body = { "user_ids" => ["U1234567890", "U0987654321"] }.to_json
166166
stub_request(:get, "https://api.line.me/v2/bot/followers/ids")
167167
.with(
168168
headers: {
@@ -176,6 +176,41 @@
176176
expect(status_code).to eq(200)
177177
expect(body.user_ids).to eq(["U1234567890", "U0987654321"])
178178
end
179+
180+
it 'query with only start' do
181+
response_body = { "user_ids" => ["U1234567890", "U0987654321"], "next" => "nExT Token" }.to_json
182+
stub_request(:get, "https://api.line.me/v2/bot/followers/ids?start=from%20previous%20NEXT")
183+
.with(
184+
headers: {
185+
'Authorization' => "Bearer test-channel-access-token"
186+
}
187+
)
188+
.to_return(status: response_code, body: response_body, headers: { 'Content-Type' => 'application/json' })
189+
190+
body, status_code, headers = client.get_followers_with_http_info(start: "from previous NEXT")
191+
192+
expect(status_code).to eq(200)
193+
expect(body.user_ids).to eq(["U1234567890", "U0987654321"])
194+
expect(body._next).to eq("nExT Token")
195+
end
196+
197+
it 'query with limit and start' do
198+
response_body = { "user_ids" => ["U1234567890", "U0987654321"], "next" => "nExT Token" }.to_json
199+
stub_request(:get, "https://api.line.me/v2/bot/followers/ids?limit=10&start=from%20previous%20NEXT")
200+
.with(
201+
headers: {
202+
'Authorization' => "Bearer test-channel-access-token"
203+
}
204+
)
205+
.to_return(status: response_code, body: response_body, headers: { 'Content-Type' => 'application/json' })
206+
207+
body, status_code, headers = client.get_followers_with_http_info(start: "from previous NEXT", limit: 10)
208+
209+
expect(status_code).to eq(200)
210+
expect(body.user_ids).to eq(["U1234567890", "U0987654321"])
211+
expect(body._next).to eq("nExT Token")
212+
end
213+
179214
end
180215

181216
describe 'GET /v2/bot/message/aggregation/list' do

0 commit comments

Comments
 (0)