add next_page?

This commit is contained in:
simon lehericey 2023-10-17 23:42:20 +02:00 committed by Paul Chavard
parent 137c19cce8
commit b37f2c6825
2 changed files with 31 additions and 0 deletions

View file

@ -66,6 +66,10 @@ module Connections
after.present? || (result_size == limit && inverted)
end
def next_page?(before, result_size, limit, inverted)
before.present? || (result_size == limit && !inverted)
end
def load_nodes
@nodes ||= begin
ensure_valid_params

View file

@ -83,4 +83,31 @@ RSpec.describe Connections::CursorConnection do
it { is_expected.to be true }
end
end
describe '.next_page?' do
let(:before) { nil }
let(:result_size) { nil }
let(:limit) { nil }
let(:inverted) { false }
subject do
cursor = Connections::CursorConnection.new(Dossier)
cursor.send(:next_page?, before, result_size, limit, inverted)
end
context 'when before is present' do
let(:before) { :before }
it { is_expected.to be true }
end
context 'when not inverted and result_size == limit' do
let(:inverted) { false }
let(:result_size) { 3 }
let(:limit) { 3 }
it { is_expected.to be true }
end
end
end