Skip to content

Commit ce79cfc

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

1 file changed

Lines changed: 38 additions & 4 deletions

File tree

spec/line/bot/v2/misc_spec.rb

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
.with(
4444
body: "{\"description\":\"Test Audience\"}",
4545
headers: {
46-
'Authorization'=>"Bearer #{channel_access_token}",
47-
'Content-Type'=>'application/json',
46+
'Authorization' => "Bearer #{channel_access_token}",
47+
'Content-Type' => 'application/json',
4848
}
4949
)
5050
.to_return(status: 202, body: "{\"description\": \"Test Audience response\"}", headers: {})
@@ -142,7 +142,7 @@
142142
it "doesn't require bearer token" do
143143
stub_request(:post, "https://api.line.me/v2/oauth/accessToken")
144144
.with(
145-
body: {"clientId"=>"test-client-id", "clientSecret"=>"test-client-secret", "grantType"=>"client_credentials" }
145+
body: { "clientId" => "test-client-id", "clientSecret" => "test-client-secret", "grantType" => "client_credentials" }
146146
)
147147
.to_return(status: response_code, body: response_body, headers: { 'Content-Type' => 'application/json' })
148148

@@ -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,40 @@
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
179213
end
180214

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

0 commit comments

Comments
 (0)