|
6 | 6 | describe "#initialize" do |
7 | 7 | context "lazy cache resolver state management" do |
8 | 8 | let(:state_key) { :lazy_cache_resolver_statez } |
| 9 | + let(:gql_context) { instance_double "Context" } |
| 10 | + let(:fragment) { GraphQL::FragmentCache::Fragment.new(gql_context) } |
| 11 | + |
| 12 | + before do |
| 13 | + allow(gql_context).to receive(:namespace).and_return({}) |
| 14 | + end |
9 | 15 |
|
10 | 16 | it "adds lazy state property to the query context" do |
11 | 17 | context = {} |
12 | 18 |
|
13 | 19 | expect(context).not_to have_key(state_key) |
14 | 20 |
|
15 | | - GraphQL::FragmentCache::Schema::LazyCacheResolver.new(nil, context, {}) |
| 21 | + GraphQL::FragmentCache::Schema::LazyCacheResolver.new(fragment, context, {}) |
16 | 22 |
|
17 | 23 | expect(context).to have_key(state_key) |
18 | 24 | end |
19 | 25 |
|
20 | 26 | it "has :pending_fragments Set in state" do |
21 | 27 | context = {} |
22 | 28 |
|
23 | | - GraphQL::FragmentCache::Schema::LazyCacheResolver.new({}, context, {}) |
| 29 | + GraphQL::FragmentCache::Schema::LazyCacheResolver.new(fragment, context, {}) |
24 | 30 |
|
25 | 31 | expect(context[state_key]).to have_key(:pending_fragments) |
26 | 32 | expect(context[state_key][:pending_fragments]).to be_instance_of(Set) |
|
29 | 35 | it "has :resolved_fragments Hash in state" do |
30 | 36 | context = {} |
31 | 37 |
|
32 | | - GraphQL::FragmentCache::Schema::LazyCacheResolver.new({}, context, {}) |
| 38 | + GraphQL::FragmentCache::Schema::LazyCacheResolver.new(fragment, context, {}) |
33 | 39 |
|
34 | 40 | expect(context[state_key]).to have_key(:resolved_fragments) |
35 | 41 | expect(context[state_key][:resolved_fragments]).to be_instance_of(Hash) |
|
39 | 45 | context = {} |
40 | 46 | fragments = [] |
41 | 47 |
|
42 | | - 3.times { fragments.push(Object.new) } |
| 48 | + 3.times { fragments.push(GraphQL::FragmentCache::Fragment.new(gql_context)) } |
43 | 49 |
|
44 | 50 | fragments.each do |f| |
45 | 51 | GraphQL::FragmentCache::Schema::LazyCacheResolver.new(f, context, {}) |
|
51 | 57 | end |
52 | 58 | end |
53 | 59 | end |
54 | | - |
55 | | - it "has :resolve method" do |
56 | | - lazy_cache_resolver = GraphQL::FragmentCache::Schema::LazyCacheResolver.new({}, {}, {}) |
57 | | - |
58 | | - expect(lazy_cache_resolver).to respond_to(:resolve) |
59 | | - end |
60 | 60 | end |
0 commit comments