Skip to content

Commit a62b21a

Browse files
committed
Add a couple more specs to satisfy curiosity
1 parent 776da3a commit a62b21a

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

spec/inertia/rendering_spec.rb

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,59 @@
138138
)
139139
end
140140
end
141+
142+
context 'with both partial and except dot notation' do
143+
let(:headers) do
144+
{
145+
'X-Inertia' => true,
146+
'X-Inertia-Partial-Component' => 'TestComponent',
147+
'X-Inertia-Partial-Data' => 'lazy,nested.deeply_nested',
148+
'X-Inertia-Partial-Except' => 'nested.deeply_nested.first',
149+
}
150+
end
151+
152+
before { get deeply_nested_props_path, headers: headers }
153+
154+
it 'renders the partial data and excludes the excepted data' do
155+
expect(response.parsed_body['props']).to eq(
156+
'always' => 'always prop',
157+
'lazy' => 'lazy param',
158+
'nested' => {
159+
'deeply_nested' => {
160+
'second' => false,
161+
'what_about_nil' => nil,
162+
'what_about_empty_hash' => {},
163+
'deeply_nested_always' => 'deeply nested always prop',
164+
'deeply_nested_lazy' => 'deeply nested lazy prop',
165+
},
166+
},
167+
)
168+
end
169+
end
170+
171+
context 'with nonsensical partial data that includes and excludes the same prop and tries to exclude an always prop' do
172+
let(:headers) do
173+
{
174+
'X-Inertia' => true,
175+
'X-Inertia-Partial-Component' => 'TestComponent',
176+
'X-Inertia-Partial-Data' => 'lazy',
177+
'X-Inertia-Partial-Except' => 'lazy,always',
178+
}
179+
end
180+
181+
before { get deeply_nested_props_path, headers: headers }
182+
183+
it 'excludes everything but Always props' do
184+
expect(response.parsed_body['props']).to eq(
185+
'always' => 'always prop',
186+
'nested' => {
187+
'deeply_nested' => {
188+
'deeply_nested_always' => 'deeply nested always prop',
189+
},
190+
},
191+
)
192+
end
193+
end
141194
end
142195

143196
context 'partial except rendering' do

0 commit comments

Comments
 (0)