Skip to content

Commit b4c8331

Browse files
committed
Fix failing specs
1 parent 3e66bd1 commit b4c8331

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

superglue/lib/action_creators/requests.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ the same page. Or if you're sure you want to proceed, use force: true.
133133
}
134134
}
135135

136-
dispatch(receiveResponse({ pageKey, response: json }))
136+
dispatch(
137+
receiveResponse({
138+
pageKey,
139+
response: JSON.parse(JSON.stringify(json)),
140+
})
141+
)
137142

138143
const existingPage = createProxy(
139144
pages[pageKey],
@@ -248,7 +253,12 @@ to the same page.
248253
),
249254
}
250255

251-
dispatch(receiveResponse({ pageKey, response: json }))
256+
dispatch(
257+
receiveResponse({
258+
pageKey,
259+
response: JSON.parse(JSON.stringify(json)),
260+
})
261+
)
252262

253263
const existingPage = createProxy(
254264
pages[pageKey],

superglue/spec/lib/action_creators.spec.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ describe('action creators', () => {
241241
})
242242
})
243243

244-
it.only('uses existing fragment nodes as placeholders for deferred fragments', () => {
244+
it('uses existing fragment nodes as placeholders for deferred fragments', () => {
245245
const initialState = () => {
246246
return {
247247
pages: {
@@ -357,6 +357,10 @@ describe('action creators', () => {
357357
type: '@@superglue/BEFORE_FETCH',
358358
payload: expect.any(Object),
359359
},
360+
{
361+
type: '@@superglue/RECEIVE_RESPONSE',
362+
payload: expect.any(Object),
363+
},
360364
{
361365
type: '@@superglue/HANDLE_GRAFT',
362366
payload: {
@@ -475,6 +479,10 @@ describe('action creators', () => {
475479
type: '@@superglue/BEFORE_FETCH',
476480
payload: expect.any(Object),
477481
},
482+
{
483+
type: '@@superglue/RECEIVE_RESPONSE',
484+
payload: expect.any(Object),
485+
},
478486
{
479487
type: '@@superglue/HANDLE_GRAFT',
480488
payload: {
@@ -788,6 +796,10 @@ describe('action creators', () => {
788796
],
789797
},
790798
},
799+
{
800+
type: '@@superglue/RECEIVE_RESPONSE',
801+
payload: expect.any(Object),
802+
},
791803
{
792804
type: '@@superglue/SAVE_RESPONSE',
793805
payload: {
@@ -841,6 +853,7 @@ describe('action creators', () => {
841853
data: {
842854
posts: ['post 2'],
843855
},
856+
action: 'savePage',
844857
fragments: [],
845858
csrfToken: 'token',
846859
assets: [],
@@ -875,11 +888,16 @@ describe('action creators', () => {
875888
],
876889
},
877890
},
891+
{
892+
type: '@@superglue/RECEIVE_RESPONSE',
893+
payload: expect.any(Object),
894+
},
878895
{
879896
type: '@@superglue/SAVE_RESPONSE',
880897
payload: {
881898
pageKey: '/foo',
882899
page: {
900+
action: 'savePage',
883901
data: { posts: ['post 1', 'post 2'] },
884902
csrfToken: 'token',
885903
assets: [],
@@ -1550,6 +1568,10 @@ describe('action creators', () => {
15501568
type: '@@superglue/COPY_PAGE',
15511569
payload: { from: '/current', to: '/details' },
15521570
},
1571+
{
1572+
type: '@@superglue/RECEIVE_RESPONSE',
1573+
payload: expect.any(Object),
1574+
},
15531575
{
15541576
type: '@@superglue/HANDLE_GRAFT',
15551577
payload: expect.any(Object),
@@ -1558,6 +1580,7 @@ describe('action creators', () => {
15581580

15591581
store.dispatch(visit('/details?props_at=data.address')).then((meta) => {
15601582
expect(allSuperglueActions(store)).toEqual(expectedActions)
1583+
}).finally(() => {
15611584
done()
15621585
})
15631586
}))
@@ -1602,6 +1625,10 @@ describe('action creators', () => {
16021625
type: '@@superglue/COPY_PAGE',
16031626
payload: { from: '/current', to: '/details' },
16041627
},
1628+
{
1629+
type: '@@superglue/RECEIVE_RESPONSE',
1630+
payload: expect.any(Object),
1631+
},
16051632
{
16061633
type: '@@superglue/HANDLE_GRAFT',
16071634
payload: expect.any(Object),
@@ -1616,6 +1643,7 @@ describe('action creators', () => {
16161643
)
16171644
.then((meta) => {
16181645
expect(allSuperglueActions(store)).toEqual(expectedActions)
1646+
}).finally(() => {
16191647
done()
16201648
})
16211649
}))

0 commit comments

Comments
 (0)