diff options
Diffstat (limited to 'spec/graphql/resolvers/crm')
-rw-r--r-- | spec/graphql/resolvers/crm/contacts_resolver_spec.rb | 16 | ||||
-rw-r--r-- | spec/graphql/resolvers/crm/organizations_resolver_spec.rb | 18 |
2 files changed, 24 insertions, 10 deletions
diff --git a/spec/graphql/resolvers/crm/contacts_resolver_spec.rb b/spec/graphql/resolvers/crm/contacts_resolver_spec.rb index eba26c8c71f..98da4aeac28 100644 --- a/spec/graphql/resolvers/crm/contacts_resolver_spec.rb +++ b/spec/graphql/resolvers/crm/contacts_resolver_spec.rb @@ -41,7 +41,7 @@ RSpec.describe Resolvers::Crm::ContactsResolver do end context 'with authorized user' do - it 'does not rise an error and returns all contacts' do + it 'does not rise an error and returns all contacts in the correct order' do group.add_reporter(user) expect { resolve_contacts(group) }.not_to raise_error @@ -61,20 +61,26 @@ RSpec.describe Resolvers::Crm::ContactsResolver do end context 'when no filter is provided' do - it 'returns all the contacts' do - expect(resolve_contacts(group)).to match_array([contact_a, contact_b]) + it 'returns all the contacts in the correct order' do + expect(resolve_contacts(group)).to eq([contact_a, contact_b]) end end context 'when search term is provided' do it 'returns the correct contacts' do - expect(resolve_contacts(group, { search: "x@test.com" })).to match_array([contact_b]) + expect(resolve_contacts(group, { search: "x@test.com" })).to contain_exactly(contact_b) end end context 'when state is provided' do it 'returns the correct contacts' do - expect(resolve_contacts(group, { state: :inactive })).to match_array([contact_a]) + expect(resolve_contacts(group, { state: :inactive })).to contain_exactly(contact_a) + end + end + + context 'when ids are provided' do + it 'returns the correct contacts' do + expect(resolve_contacts(group, { ids: [contact_a.to_global_id] })).to contain_exactly(contact_a) end end end diff --git a/spec/graphql/resolvers/crm/organizations_resolver_spec.rb b/spec/graphql/resolvers/crm/organizations_resolver_spec.rb index c80caf91f90..323f134ffc3 100644 --- a/spec/graphql/resolvers/crm/organizations_resolver_spec.rb +++ b/spec/graphql/resolvers/crm/organizations_resolver_spec.rb @@ -35,7 +35,7 @@ RSpec.describe Resolvers::Crm::OrganizationsResolver do end context 'with authorized user' do - it 'does not rise an error and returns all organizations' do + it 'does not rise an error and returns all organizations in the correct order' do group.add_reporter(user) expect { resolve_organizations(group) }.not_to raise_error @@ -55,20 +55,28 @@ RSpec.describe Resolvers::Crm::OrganizationsResolver do end context 'when no filter is provided' do - it 'returns all the organizations' do - expect(resolve_organizations(group)).to match_array([organization_a, organization_b]) + it 'returns all the organizations in the correct order' do + expect(resolve_organizations(group)).to eq([organization_a, organization_b]) end end context 'when search term is provided' do it 'returns the correct organizations' do - expect(resolve_organizations(group, { search: "def" })).to match_array([organization_b]) + expect(resolve_organizations(group, { search: "def" })).to contain_exactly(organization_b) end end context 'when state is provided' do it 'returns the correct organizations' do - expect(resolve_organizations(group, { state: :inactive })).to match_array([organization_a]) + expect(resolve_organizations(group, { state: :inactive })).to contain_exactly(organization_a) + end + end + + context 'when ids are provided' do + it 'returns the correct organizations' do + expect(resolve_organizations(group, { + ids: [organization_b.to_global_id] + })).to contain_exactly(organization_b) end end end |